It should almost certainly be included in Suggests, and nowhere else. If that means your tests are skipped, you should feel free to warn the user in your test messages: but it shouldn't cause your tests to fail.
I guess my worry is that my upstream dependencies will break something without knowing it because the tests won't fail unless httptest is installed. I really wish there was a way to indicate dependencies for testing purposes only. (And, oops, you're right, I meant that I was considering including httptest in Imports not Depends)
On Fri, Jan 8, 2021 at 12:04 PM David Bosak <dbosak01 at gmail.com> wrote:
Namespace in Imports field not imported from: ?httptest?
All declared Imports should be used.
I?ve seen that note before when I forgot to remove a @import reference in the Roxygen comments. Or it is still in the NAMESPACE file when I don?t want it to be. Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10 *From: *Duncan Murdoch <murdoch.duncan at gmail.com> *Sent: *Friday, January 8, 2021 11:15 AM *To: *Greg Freedman Ellis <gdfermail at gmail.com>; r-package-devel at r-project.org *Subject: *Re: [R-pkg-devel] Package used unconditionally only in testing On 08/01/2021 9:17 a.m., Greg Freedman Ellis wrote:
Hi all,
I'm trying to update a package to conform to pass tests given
`_R_CHECK_DEPENDS_ONLY_=TRUE`.
In this package, we only use the package `httptest` during testing, but
the
tests are (almost) meaningless if it is not installed, so I would like to
indicate that it is a required package rather than skipping tests if it
is
not installed.
This sounds wrong. I don't know the httptest package, but I assume that since you were only using it for testing, I might be interested in using your package even if I wasn't interested in installing httptest. Making it a hard requirement would force me to install httptest.
If I move `httptest` to Depends, then I get the error CRAN check note:
Namespace in Imports field not imported from: ?httptest?
All declared Imports should be used.
You *definitely* shouldn't include it in Depends: that would force it onto the search list, and potentially break other things that I'm running, e.g. if they have name conflicts with it. You *probably* shouldn't include it in Imports. Why force me to load another package if I'll never use it? There's a tiny chance that would push my memory use over the edge, and my own code would fail. It should almost certainly be included in Suggests, and nowhere else. If that means your tests are skipped, you should feel free to warn the user in your test messages: but it shouldn't cause your tests to fail.
I think this would best be solved by a DESCRIPTION field that indicates a
package is required, but only for tests, but I do not see such a field.
The
only solution I can think of is to have a trivial import of `httptest` in
the main package to silence the NOTE. Is there a better solution?
Most users aren't going to run your tests, so they shouldn't be forced to install software that would let them do so. Duncan Murdoch
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel