diff options
author | Dmitry B <oxitnik@gmail.com> | 2017-10-06 22:12:22 +0300 |
---|---|---|
committer | Dmitry B <oxitnik@gmail.com> | 2017-10-06 22:12:22 +0300 |
commit | e8e8ff123b1efead6618c08ea960203644d05a95 (patch) | |
tree | 4330f3cc1dad69c80e9e82306696a8a1ad597f61 /tests | |
parent | 0ccf008cf85abe63f0415aae74f6667107302c3b (diff) |
comments for 'Use termporary config in tests'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 2 | ||||
-rw-r--r-- | tests/features/environment.py | 2 | ||||
-rw-r--r-- | tests/test_rowlimit.py | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 85433c53..5eceb462 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,4 +34,6 @@ def exception_formatter(): @pytest.fixture(scope="session", autouse=True) def temp_config(tmpdir_factory): + # this function runs on start of test session. + # use temporary directory for config home so user config will not be used os.environ['XDG_CONFIG_HOME'] = str(tmpdir_factory.mktemp('data')) diff --git a/tests/features/environment.py b/tests/features/environment.py index 81c54ad4..80828f01 100644 --- a/tests/features/environment.py +++ b/tests/features/environment.py @@ -98,8 +98,8 @@ def before_all(context): context.fixture_data = fixutils.read_fixture_files() + # use temporary directory as config home context.env_config_home = tempfile.mkdtemp(prefix='pgcli_home_') - os.environ['XDG_CONFIG_HOME'] = context.env_config_home diff --git a/tests/test_rowlimit.py b/tests/test_rowlimit.py index fd732eec..91389a15 100644 --- a/tests/test_rowlimit.py +++ b/tests/test_rowlimit.py @@ -3,6 +3,9 @@ from mock import Mock import pytest +# We need this fixtures beacause we need PGCli object to be created +# after test collection so it has config loaded from temp directory + @pytest.fixture(scope="module") def default_pgcli_obj(): return PGCli() |