Namespace exports changing upon devtools::test()

Running devtools::test() changes the list of exported functions.

> getNamespaceExports("my_package")
[1] "exported_1"  "exported_2" ...
> devtools::test()
Loading my_package
Testing my_package
...
══ Results ══════════════════════════════════════════════════════════════════════════════════════
Duration: 0.4 s

OK:       93
Failed:   1
Warnings: 0
Skipped:  0

Your tests are shining!
... error info below ...
> getNamespaceExports("my_package")
[1] "exported_1" "exported_2" "unexported_1" "unexported_2" ...

Apologies for the lack of a repex, I wasn't sure on how to write one given the problem

1 Like

This has been figured out. From the documentation for testthat::test_dir():

Environments

Each test is run in a clean environment to keep tests as isolated as possible. For package tests, that environment that inherits from the package's namespace environment, so that tests can access internal functions and objects.

2 Likes

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.