-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let users run test
with export_all=FALSE
#1201
Comments
But if |
Actually devtools runs tests in an environment with the package under tests namespace as a parent. So we can set #1210 does this. |
I found this issue when searching for a work around that wouldn't require changing the devtools. I think this is a generic way to get around the in a test.R file: context('...')
# any setup stuff here
test_that('...', {
## set the parent of current environment to the global environment ##
e <- environment()
pe <- parent.env(e)
parent.env(e) <- globalenv()
pkgpath <- find.package('pkgname')
devtools::load_all(pkgpath, export_all=FALSE, quiet=TRUE)
## Run all tests with nonexported functions ##
## Reset environment for subsequent tests ##
parent.env(e) <- pe
devtools::load_all(pkgpath, export_all=TRUE, quiet=TRUE)
}) Since However, it is possible to manipulate the environment stack from a calling environment. Above, I've set the parent to the global environment, but one could as easily set it to a new/empty one. Just make sure to reset / reload or you might break other tests. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
At the moment
test
quietly callsload_all
with the defaultexport_all=TRUE
. This means:print.foo
will work even if it's not exported).test
has run.The text was updated successfully, but these errors were encountered: