summaryrefslogtreecommitdiff
path: root/test/test_farm.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-09-26 20:08:24 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-09-26 20:08:24 -0400
commitecf5b0dfcf5b15d8325666beed0c101efc35ec23 (patch)
treec84d662dbd398602696e573aa03c483ff456b8bb /test/test_farm.py
parent13a69926134a926ea047d91bff06865bd5097a04 (diff)
downloadpython-coveragepy-git-ecf5b0dfcf5b15d8325666beed0c101efc35ec23.tar.gz
HTML report includes non-relative code units also. Fixes issue #11, though the paths displayed in the HTML are kind of heinous.
Diffstat (limited to 'test/test_farm.py')
-rw-r--r--test/test_farm.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/test_farm.py b/test/test_farm.py
index 8cceacce..bc1d7a30 100644
--- a/test/test_farm.py
+++ b/test/test_farm.py
@@ -49,6 +49,16 @@ class FarmTestCase(object):
os.chdir(newdir)
return cwd
+ def addtopath(self, directory):
+ """Add `directory` to the path, and return the old path."""
+ oldpath = sys.path[:]
+ sys.path.insert(0, directory)
+ return oldpath
+
+ def restorepath(self, path):
+ """Restore the system path to `path`."""
+ sys.path = path
+
def __call__(self):
"""Execute the test from the run.py file.
@@ -143,7 +153,7 @@ class FarmTestCase(object):
finally:
self.cd(cwd)
- def runfunc(self, fn, rundir="src"):
+ def runfunc(self, fn, rundir="src", addtopath=None):
"""Run a function.
`fn` is a callable.
@@ -152,10 +162,12 @@ class FarmTestCase(object):
"""
cwd = self.cd(rundir)
+ oldpath = self.addtopath(addtopath)
try:
fn()
finally:
self.cd(cwd)
+ self.restorepath(oldpath)
def compare(self, dir1, dir2, filepattern=None, size_within=0,
left_extra=False, right_extra=False, scrubs=None