Skip to content
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

Set option before pkg is loaded #1702

Closed
majr-red opened this issue Oct 4, 2022 · 2 comments
Closed

Set option before pkg is loaded #1702

majr-red opened this issue Oct 4, 2022 · 2 comments

Comments

@majr-red
Copy link

majr-red commented Oct 4, 2022

The package I'm writing tests for reads local config files during .onLoad(), but this behaviour needs to be skipped during testing (config can be also be done explicitly after loading).

I thought to make it conditional on an option read during .onLoad(), (details here) but I can't see a way to make testthat set the option in the test env before the package is loaded.

Would it be possible to enable options to be set in the test env before loading, or is there a better way to skip such behaviour during testing?

@hadley
Copy link
Member

hadley commented Mar 23, 2023

One possible solution would be instead of doing the work onLoad, do it lazily the first time it's needed.

@hadley hadley closed this as completed Mar 23, 2023
@majr-red
Copy link
Author

Thanks. I hadn't considered doing it lazily, and I think that could work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants