diff options
-rw-r--r-- | tests/conftest.py | 17 | ||||
-rw-r--r-- | tests/mixins.py | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 6ef42fc1..581329bb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,6 +16,7 @@ import pytest from coverage import env from coverage.exceptions import _StopEverything +from coverage.files import set_relative_directory # Pytest will rewrite assertions in test modules, but not elsewhere. @@ -72,6 +73,22 @@ def reset_sys_path(): sys.path[:] = sys_path +@pytest.fixture(autouse=True) +def reset_environment(): + """Make sure a test setting an envvar doesn't leak into another test.""" + old_environ = os.environ.copy() + yield + os.environ.clear() + os.environ.update(old_environ) + + +@pytest.fixture(autouse=True) +def reset_filesdotpy_globals(): + """coverage/files.py has some unfortunate globals. Reset them every test.""" + set_relative_directory() + yield + + TRACK_TESTS = False TEST_TXT = "/tmp/tests.txt" diff --git a/tests/mixins.py b/tests/mixins.py index e55a05b9..25663c6e 100644 --- a/tests/mixins.py +++ b/tests/mixins.py @@ -66,10 +66,9 @@ class TempDirMixin: # nose's caching importer can get confused. The full path prevents # problems. sys.path.insert(0, os.getcwd()) - - yield None + yield else: - yield None + yield def make_file(self, filename, text="", bytes=b"", newline=None): """Make a file. See `tests.helpers.make_file`""" |