summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/features/environment.py2
-rw-r--r--tests/test_rowlimit.py3
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()