diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 19:59:48 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-13 19:59:48 -0500 |
| commit | 543ff12a09952b132abd9aa863d4170c4e2523f4 (patch) | |
| tree | edb5c42983dea78eb58be0a7f587e334c0aed9ae | |
| parent | 5e09c8140d43822815a96c0020c92f0d62090e0c (diff) | |
| parent | 8efcf6c1745f9e3a3acfc15b68efade1ab4ead20 (diff) | |
| download | python-coveragepy-543ff12a09952b132abd9aa863d4170c4e2523f4.tar.gz | |
Merge Ben Finney's use-os-path-module fixes.
| -rw-r--r-- | coverage/files.py | 6 | ||||
| -rw-r--r-- | test/backtest.py | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/coverage/files.py b/coverage/files.py index ba228c2..fb59732 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -6,7 +6,7 @@ class FileLocator(object): """Understand how filenames work.""" def __init__(self): - self.relative_dir = self.abs_file(os.curdir) + os.sep + self.relative_dir = self.abs_file(os.curdir) # Cache of results of calling the canonical_filename() method, to # avoid duplicating work. @@ -23,7 +23,9 @@ class FileLocator(object): FileLocator was constructed. """ - return filename.replace(self.relative_dir, "") + common_prefix = os.path.commonprefix( + [filename, self.relative_dir + os.sep]) + return filename[len(common_prefix):] def canonical_filename(self, filename): """Return a canonical filename for `filename`. diff --git a/test/backtest.py b/test/backtest.py index 12bdbc9..58b1647 100644 --- a/test/backtest.py +++ b/test/backtest.py @@ -29,7 +29,8 @@ else: if sys.hexversion > 0x03000000 and cmd.startswith("coverage "): # We don't have a coverage command on 3.x, so fix it up to call the # script. Eventually we won't need this. - cmd = "python " + sys.prefix + os.sep + "Scripts" + os.sep + cmd + script_path = os.path.join(sys.prefix, "Scripts", cmd) + cmd = "python " + script_path proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
