From 5140ca64f6d22ccb07fdc964eeaa8d50bc3e551b 2020-03-23 16:01:02 From: Brett Smith Date: 2020-03-23 16:01:02 Subject: [PATCH] tests: Clean the environment before running tests. As we start reading more sensitive user configuration (like RT credentials), this fixture makes it simpler to ensure that the tests never read the user's real configuration, which could lead to problems like passwords in tracebacks. --- diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..6e40f46b04f6abac5f646d26da8640345abf20d8 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +import os + +import pytest + +from . import testutil + +@pytest.fixture(scope='session', autouse=True) +def clean_environment(): + os.environ.pop('CONSERVANCY_REPOSITORY', None) diff --git a/tests/test_config.py b/tests/test_config.py index 589ba456ca4d01b31926ead153fe57985efe80a0..62aea03fb5ad47d3891eafbd811cb42e21de0dfd 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -39,6 +39,5 @@ def test_repository_from_environment(): assert config.repository_path().parts == ('/', 'usr', 'local') def test_no_repository(): - with update_environ(CONSERVANCY_REPOSITORY=None): - config = config_mod.Config() - assert config.repository_path() is None + config = config_mod.Config() + assert config.repository_path() is None