From 4bb849f39914138316b33dec2ddb427fb5142b41 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 10 Jul 2009 18:50:19 -0400 Subject: Py3k: manipulating PYTHONPATH seems different under Py 3.x, so do it differently. --- test/coveragetest.py | 10 +++++++--- 1 file 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 -- cgit v1.2.1