-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IXMP_DATA / execute all tests in temporary directories #130
Conversation
- New class ixmp.config.Config to regularize config handling. - Remove ixmp.default_paths, ixmp.default_path_constants. - cli.config(): use Config.save(). - Scenario__init__(): use Config.find_dbprops() and Config.get(). - conftest.py: new fixture 'tmp_env' and hook 'pytest_sessionstart'. - test_config.py: test Config features. - test_core.py: use pytest 'caplog' fixture to test that configuration values are used. - test_tutorials.py: use 'tmp_env' to force tutorial execution in a sandbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @khaeru Thanks so much!! One passing comment then I think its good to go!
Hey @khaeru let me know if there's anything else to do here. Otherwise as soon as it passes, we can pull and continue with other PRs! |
Done, please go ahead and merge. |
thanks @khaeru, great addition! |
This code causes all tests to be executed in temporary directories, without touching the user's local database or configuration file. This is accomplished by checking a new environment variable
IXMP_DATA
, which points to a directory that is used for bothconfig.json
and theDEFAULT_LOCAL_DB_PATH
. Along the way, handling of configuration keys is formalized a little.To check that the code works as advertised, one can make one's own (user) ixmp data directory read-only, e.g.
$ chmod -w ~/.local/share/ixmp
. Then run the tests. The tests pass; this shows thatixmp-config
calls in tests, and any local databases created/used, are not written in this directory.Closes #124.
ixmp.config.Config
to regularize config handling.ixmp.default_paths
,ixmp.default_path_constants
submodules.PR checklist: