diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 20:45:52 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 20:45:52 -0500 |
commit | f9816c233dff7cb890e757f76d7afbe31fe7fd6a (patch) | |
tree | e1bfd3b45868079ba60355a7a12245d373a9f445 | |
parent | 05e1c91b3cb36e6901d925b47f98787915befa23 (diff) | |
download | python-coveragepy-f9816c233dff7cb890e757f76d7afbe31fe7fd6a.tar.gz |
Nicer handling of missing environment variables.
-rw-r--r-- | test/coveragetest.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index c82891e..6366970 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -87,12 +87,12 @@ class CoverageTest(TestCase): self.environ_undos[name] = os.environ.get(name) os.environ[name] = value - def original_environ(self, name): + def original_environ(self, name, if_missing=None): """The environment variable `name` from when the test started.""" if name in self.environ_undos: return self.environ_undos[name] else: - return os.environ.get(name) + return os.environ.get(name, if_missing) def undo_environ(self): """Undo all the changes made by `set_environ`.""" @@ -324,11 +324,9 @@ class CoverageTest(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 = self.original_environ('PYTHONPATH') + pypath = self.original_environ('PYTHONPATH', "") if pypath: pypath += os.pathsep - else: - pypath = "" pypath += testmods + os.pathsep + zipfile self.set_environ('PYTHONPATH', pypath) |