diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-10 18:50:19 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-10 18:50:19 -0400 |
commit | efd4240423fc6cfae9710bd11dcc64d80792b883 (patch) | |
tree | 9e795c862267d2dc1ac83d9c97ceabdb50497413 | |
parent | 9e07258da097f539da03ace171372fc15effa1cb (diff) | |
download | python-coveragepy-efd4240423fc6cfae9710bd11dcc64d80792b883.tar.gz |
Py3k: manipulating PYTHONPATH seems different under Py 3.x, so do it differently.
-rw-r--r-- | test/coveragetest.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index 9588a7f..1502770 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -32,6 +32,9 @@ class CoverageTest(unittest.TestCase): self.old_dir = os.getcwd() os.chdir(self.temp_dir) + # Preserve changes to PYTHONPATH. + self.old_pypath = os.environ.get('PYTHONPATH', '') + # Modules should be importable from this temp directory. self.old_syspath = sys.path[:] sys.path.insert(0, '') @@ -45,9 +48,10 @@ class CoverageTest(unittest.TestCase): sys.stdout = Tee(sys.stdout, self.captured_stdout) def tearDown(self): - # Restore the original sys.path + # Restore the original sys.path and PYTHONPATH sys.path = self.old_syspath - + os.environ['PYTHONPATH'] = self.old_pypath + # Get rid of the temporary directory. os.chdir(self.old_dir) shutil.rmtree(self.temp_root) @@ -203,7 +207,7 @@ class CoverageTest(unittest.TestCase): here = os.path.dirname(self.nice_file(coverage.__file__, "..")) testmods = self.nice_file(here, 'test/modules') zipfile = self.nice_file(here, 'test/zipmods.zip') - pypath = os.environ.get('PYTHONPATH', '') + pypath = self.old_pypath if pypath: pypath += os.pathsep pypath += testmods + os.pathsep + zipfile |