summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-11-04 07:22:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-11-04 07:22:42 -0400
commit14ff42a34de245fcc603f7431eb0ae5912febcad (patch)
tree088856f4075ca1387e2d5b7d96563fc31d36e211 /tests/coveragetest.py
parent07511758c6307bb39923a2f9f718003d50d9fc8c (diff)
downloadpython-coveragepy-git-14ff42a34de245fcc603f7431eb0ae5912febcad.tar.gz
Use the real implementation of del_environ
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py42
1 files changed, 4 insertions, 38 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 5cd94e28..29d634c4 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -28,44 +28,6 @@ from coverage.misc import StopEverything
from tests.helpers import run_command, SuperModuleCleaner
-# TEMPORARY to see if it helps.
-class EnvironmentAwareMixin(unittest.TestCase):
- """A test case mixin that isolates changes to the environment."""
-
- def setUp(self):
- super(EnvironmentAwareMixin, self).setUp()
-
- # Record environment variables that we changed with set_environ.
- self._environ_undos = {}
-
- self.addCleanup(self._cleanup_environ)
-
- def set_environ(self, name, value):
- """Set an environment variable `name` to be `value`.
-
- The environment variable is set, and record is kept that it was set,
- so that `cleanup_environ` can restore its original value.
-
- """
- if name not in self._environ_undos:
- self._environ_undos[name] = os.environ.get(name)
- os.environ[name] = value
-
- def del_environ(self, name):
- """Delete an environment variable, unless we set it."""
- if name not in self._environ_undos and name in os.environ:
- self._environ_undos[name] = os.environ.get(name)
- del os.environ[name]
-
- def _cleanup_environ(self):
- """Undo all the changes made by `set_environ`."""
- for name, value in self._environ_undos.items():
- if value is None:
- del os.environ[name]
- else:
- os.environ[name] = value
-
-
# Status returns for the command line.
OK, ERR = 0, 1
@@ -499,6 +461,10 @@ class CoverageTest(
pypath += testmods + os.pathsep + zipfile
self.set_environ(pythonpath_name, pypath)
+ # There are environment variables that we set when we are running the
+ # coverage test suite under coverage. We don't want these environment
+ # variables to leak into subprocesses we start for a test. Delete them
+ # before running the subprocess command.
self.del_environ("COVERAGE_COVERAGE")
self.del_environ("COVERAGE_PROCESS_START")