summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/config.py1
-rw-r--r--coverage/files.py5
-rw-r--r--tests/test_config.py6
-rw-r--r--tests/test_files.py2
4 files changed, 10 insertions, 4 deletions
diff --git a/coverage/config.py b/coverage/config.py
index 62f281ad..b8789fbf 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -534,5 +534,6 @@ def read_coverage_config(config_file, **kwargs):
config.data_file = os.path.expanduser(config.data_file)
config.html_dir = os.path.expanduser(config.html_dir)
config.xml_output = os.path.expanduser(config.xml_output)
+ config.paths = {k: [os.path.expanduser(f) for f in v] for k, v in config.paths.items()}
return config
diff --git a/coverage/files.py b/coverage/files.py
index 2836d4e5..5c2ff1ac 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -159,9 +159,8 @@ else:
@contract(returns='unicode')
-def abs_file(filename):
- """Return the absolute normalized form of `filename`."""
- path = os.path.expandvars(os.path.expanduser(filename))
+def abs_file(path):
+ """Return the absolute normalized form of `path`."""
try:
path = os.path.realpath(path)
except UnicodeError:
diff --git a/tests/test_config.py b/tests/test_config.py
index 7979a84d..fe9e001e 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -275,6 +275,11 @@ class ConfigTest(CoverageTest):
exclude_lines =
~/data.file
~joe/html_dir
+
+ [paths]
+ mapping =
+ ~/src
+ ~joe/source
""")
def expanduser(s):
"""Fake tilde expansion"""
@@ -288,6 +293,7 @@ class ConfigTest(CoverageTest):
self.assertEqual(cov.config.html_dir, "/Users/joe/html_dir")
self.assertEqual(cov.config.xml_output, "/Users/me/somewhere/xml.out")
self.assertEqual(cov.config.exclude_list, ["~/data.file", "~joe/html_dir"])
+ self.assertEqual(cov.config.paths, {'mapping': ['/Users/me/src', '/Users/joe/source']})
def test_tilde_in_toml_config(self):
# Config entries that are file paths can be tilde-expanded.
diff --git a/tests/test_files.py b/tests/test_files.py
index e271da1b..1aeacb51 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -357,7 +357,7 @@ class PathAliasesTest(CoverageTest):
self.assert_mapped(aliases, '/foo/bar/d2/y.py', './mysrc2/y.py')
def test_dot(self):
- cases = ['.', '..', '../other', '~']
+ cases = ['.', '..', '../other']
if not env.WINDOWS:
# The root test case was added for the manylinux Docker images,
# and I'm not sure how it should work on Windows, so skip it.