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 | 4bb849f39914138316b33dec2ddb427fb5142b41 (patch) | |
tree | 651e12e3ea76a68be6b34bc4ceabc26fecebb6ce | |
parent | 68c834ffee22ecae8574924c8827b4dd860db4b2 (diff) | |
download | python-coveragepy-git-4bb849f39914138316b33dec2ddb427fb5142b41.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 9588a7fc..1502770d 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 |