You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
I don't think you should be setting the edition outside of a given packages for exactly this reason — people will get different behaviours depending on which version they have set.
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:
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?The text was updated successfully, but these errors were encountered: