-
Notifications
You must be signed in to change notification settings - Fork 340
Description
A colleague and I just had issues with different behaviours of testthat in the same package version and R version until we figured out that he had edition 2 active and I had edition 3 active, even though none of us had ever touched the testthat settings knowingly. We are now wondering if there is an easy way to globally and permanently set the testthat edition, e.g. via a function call in .Rprofile or an environment variable?
We are aware that we can set the edition in the DESCRIPTION file, however there are instances where we found the testthat functionality to be very useful and handy outside of the unit testing framework. We also tried putting testthat::local_edition(3) in the .Rprofile, but a) testthat might not always be installed e.g. after an R version update and b) this also triggered lots of messages on deferred events:
Setting global deferred event(s).
i These will be run:
* Automatically, when the R session ends.
* On demand, if you call `withr::deferred_run()`.
i Use `withr::deferred_clear()` to clear them without executing.
Our best solution currently is to put suppressMessages(try(testthat::local_edition(3))) in the .Rprofile, to avoid different editions in the future, but this feels very hacky to us. Is there an easier way to globally and permanently set the testthat edition?