summaryrefslogtreecommitdiff
path: root/tests/test_files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-09-26 22:24:01 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-09-26 22:24:01 -0400
commit9a32586334141664fb393e56d3e1d76545993d79 (patch)
treeb29c5d3190190d7d1dfa9a90f4da729710623868 /tests/test_files.py
parente9b9419bc9a7d184070cc39bdf71924599a5e57f (diff)
downloadpython-coveragepy-git-9a32586334141664fb393e56d3e1d76545993d79.tar.gz
Allow relative paths in the [paths] aliases. #267.
Diffstat (limited to 'tests/test_files.py')
-rw-r--r--tests/test_files.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_files.py b/tests/test_files.py
index d247a395..26ae9100 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -1,6 +1,6 @@
"""Tests for files.py"""
-import os
+import os, os.path
from coverage.files import FileLocator, TreeMatcher, FnmatchMatcher
from coverage.files import PathAliases, find_python_files, abs_file
@@ -91,6 +91,8 @@ class MatcherTest(CoverageTest):
class PathAliasesTest(CoverageTest):
"""Tests for coverage/files.py:PathAliases"""
+ run_in_temp_dir = False
+
def test_noop(self):
aliases = PathAliases()
self.assertEqual(aliases.map('/ned/home/a.py'), '/ned/home/a.py')
@@ -155,6 +157,28 @@ class PathAliasesTest(CoverageTest):
mapped = aliases.map(r'/home/ned/foo/src/sub/a.py')
self.assertEqual(mapped, r'.\mysrc\sub\a.py')
+ def test_leading_wildcard(self):
+ aliases = PathAliases()
+ aliases.add('*/d1', './mysrc1')
+ aliases.add('*/d2', './mysrc2')
+ self.assertEqual(aliases.map('/foo/bar/d1/x.py'), './mysrc1/x.py')
+ self.assertEqual(aliases.map('/foo/bar/d2/y.py'), './mysrc2/y.py')
+
+
+class RelativePathAliasesTest(CoverageTest):
+ """Tests for coverage/files.py:PathAliases, with relative files."""
+
+ def test_dot(self):
+ for d in ('.', '..', '../other', '~'):
+ aliases = PathAliases()
+ aliases.add(d, '/the/source')
+ the_file = os.path.join(d, 'a.py')
+ the_file = os.path.expanduser(the_file)
+ the_file = os.path.abspath(the_file)
+
+ assert '~' not in the_file # to be sure the test is pure.
+ self.assertEqual(aliases.map(the_file), '/the/source/a.py')
+
class FindPythonFilesTest(CoverageTest):
"""Tests of `find_python_files`."""