Skip to content

Isolate tests from global config (#470)#647

Open
arpitjain099 wants to merge 1 commit into
llnl:mainfrom
arpitjain099:chore/isolate-test-config
Open

Isolate tests from global config (#470)#647
arpitjain099 wants to merge 1 commit into
llnl:mainfrom
arpitjain099:chore/isolate-test-config

Conversation

@arpitjain099

Copy link
Copy Markdown

Summary

If merged this pull request will make the test suite pass regardless of the developer's global Surfactant settings, fixing #470.

Proposed changes

ConfigManager is a process-wide singleton and, with the default config_dir=None, it reads the real user config (for example ~/.config/surfactant/config.toml). A few command modules evaluate config-backed defaults at import time, so an invalid global value like core.output_format = "" leaks into unrelated tests and fails them. I could reproduce it by writing that setting and running pytest: eight tests in test_generate.py, test_generate_symlinks.py, and test_tui.py errored with 'No "write_sbom" plugin for format "" found', and they all pass again with this change.

This adds a tests/conftest.py that points the config and data lookups at empty temporary directories, both at import time (before the command modules are imported) and per test through an autouse fixture, and clears the singleton cache so each test starts from a clean, isolated config. Existing ConfigManager tests still pass since they use explicit app names and config dirs. Thanks for taking a look.

ConfigManager is a process-wide singleton that, with the default
config_dir=None, reads the developer's real user config such as
~/.config/surfactant/config.toml. An invalid value there (for example
core.output_format = "") makes otherwise-correct tests fail, since some
command modules evaluate config-backed defaults at import time.

Add tests/conftest.py that redirects the config and data lookups to empty
temporary directories, both at import time (before command modules are
imported) and per test via an autouse fixture, and clears the singleton
cache so each test starts from a clean, isolated configuration.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant