Changeset - 5140ca64f6d2
[Not reviewed]
0 1 1
Brett Smith - 4 years ago 2020-03-23 16:01:02
brettcsmith@brettcsmith.org
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.
2 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
tests/conftest.py
Show inline comments
 
new file 100644
 
import os
 

	
 
import pytest
 

	
 
from . import testutil
 

	
 
@pytest.fixture(scope='session', autouse=True)
 
def clean_environment():
 
    os.environ.pop('CONSERVANCY_REPOSITORY', None)
tests/test_config.py
Show inline comments
...
 
@@ -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
0 comments (0 inline, 0 general)