summaryrefslogtreecommitdiff
path: root/bin/spack-python
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-12-29 02:04:28 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-30 13:01:31 -0800
commite7dc8a2bea23b013a8af4938a5eee298a1f59141 (patch)
tree78230f5c9d4da0692b6c3500c8e0b49e5d8d6a09 /bin/spack-python
parente8394324720aa6bb041e3dddba46faa14626bd85 (diff)
downloadspack-e7dc8a2bea23b013a8af4938a5eee298a1f59141.tar.gz
spack-e7dc8a2bea23b013a8af4938a5eee298a1f59141.tar.bz2
spack-e7dc8a2bea23b013a8af4938a5eee298a1f59141.tar.xz
spack-e7dc8a2bea23b013a8af4938a5eee298a1f59141.zip
tests: refactor tests to avoid persistent global state
Previously, fixtures like `config`, `database`, and `store` were module-scoped, but frequently used as test function arguments. These fixtures swap out global on setup and restore them on teardown. As function arguments, they would do the right set-up, but they'd leave the global changes in place for the whole module the function lived in. This meant that if you use `config` once, other functions in the same module would inadvertently inherit the mock Spack configuration, as it would only be torn down once all tests in the module were complete. In general, we should module- or session-scope the *STATE* required for these global objects (as it's expensive to create0, but we shouldn't module-or session scope the activation/use of them, or things can get really confusing. - [x] Make generic context managers for global-modifying fixtures. - [x] Make session- and module-scoped fixtures that ONLY build filesystem state and create objects, but do not swap out any variables. - [x] Make seeparate function-scoped fixtures that *use* the session scoped fixtures and actually swap out (and back in) the global variables like `config`, `database`, and `store`. These changes make it so that global changes are *only* ever alive for a singlee test function, and we don't get weird dependencies because a global fixture hasn't been destroyed.
Diffstat (limited to 'bin/spack-python')
0 files changed, 0 insertions, 0 deletions