Re: [R-pkg-devel] Is using global assignment in package tests allowed?
On 27 January 2022 at 11:18, Ben Bolker wrote: |I have spent hours trying to understand the scoping behaviour of | testthat, mostly without success. It may bear repeating that use of a test runner package is NOT required by CRAN Repo Policy, Writing R Extensions, or any other official text. If any one of these candidate packages is too complicated, or confusing, or lengthens your test setup, or [your reason here] then consider not using it. Choice is a good thing, and we have a free option of using one or none of the different available testing packages. Dirk -- https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] Is using global assignment in package tests allowed?
I don't know the answer to your question, but "beyond my ken" doesn't sound like a very convincing reason. Mucking with any environment that isn't yours is asking for trouble... the behavior you depend on today may come into conflict with the code you are coordinating with when you least expect it. Is your code in a public version control repo? On January 27, 2022 6:55:49 AM PST, James Pustejovsky wrote: >Hello, > >I'm writing unit tests using testthat for a package that we want to submit >to CRAN. Because of some aspect of how testthat works (which is beyond my >ken), I have only been able to get my tests to work by using global >assignment (<<-) to create some objects on which the tests are then run. >However, per CRAN policy: "Packages should not modify the global >environment (user’s workspace)." > >Does anyone know whether this policy applies to all code within the >package, including unit tests? Or does it apply just to the code and >functions in /R? >Or to all code that is executed as part of checking the package (i.e., code >that is never run can use <<-)? > >James > > [[alternative HTML version deleted]] > >__ >R-package-devel@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-package-devel -- Sent from my phone. Please excuse my brevity. __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel