+45
-2
lines changedFilter options
+45
-2
lines changed Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ Unreleased
34
34
- A ``[paths]`` setting like ``*/foo`` will now match ``foo/bar.py`` so that
35
35
relative file paths can be combined more easily.
36
36
37
+
- The setting is properly interpreted in more places, fixing `issue 1280`_.
38
+
37
39
- Fixed environment variable expansion in pyproject.toml files. It was overly
38
40
broad, causing errors outside of coverage.py settings, as described in `issue
39
41
1481`_. This is now fixed, but in rare cases will require changing your
@@ -43,6 +45,7 @@ Unreleased
43
45
implementations other than CPython or PyPy (`issue 1474`_).
44
46
45
47
.. _issue 991: https://github.com/nedbat/coveragepy/issues/991
48
+
.. _issue 1280: https://github.com/nedbat/coveragepy/issues/1280
46
49
.. _issue 1407: https://github.com/nedbat/coveragepy/issues/1407
47
50
.. _issue 1474: https://github.com/nedbat/coveragepy/issues/1474
48
51
.. _issue 1481: https://github.com/nedbat/coveragepy/issues/1481
Original file line number Diff line number Diff line change
@@ -151,7 +151,14 @@ def __init__(self, morf, coverage=None):
151
151
152
152
filename = source_for_morf(morf)
153
153
154
-
super().__init__(canonical_filename(filename))
154
+
fname = filename
155
+
canonicalize = True
156
+
if self.coverage is not None:
157
+
if self.coverage.config.relative_files:
158
+
canonicalize = False
159
+
if canonicalize:
160
+
fname = canonical_filename(filename)
161
+
super().__init__(fname)
155
162
156
163
if hasattr(morf, '__name__'):
157
164
name = morf.__name__.replace(".", os.sep)
Original file line number Diff line number Diff line change
@@ -149,7 +149,8 @@ def xml_file(self, fr, analysis, has_arcs):
149
149
# are populated later. Note that a package == a directory.
150
150
filename = fr.filename.replace("\\", "/")
151
151
for source_path in self.source_paths:
152
-
source_path = files.canonical_filename(source_path)
152
+
if not self.config.relative_files:
153
+
source_path = files.canonical_filename(source_path)
153
154
if filename.startswith(source_path.replace("\\", "/") + "/"):
154
155
rel_name = filename[len(source_path)+1:]
155
156
break
Original file line number Diff line number Diff line change
@@ -1239,6 +1239,38 @@ def test_combine_no_suffix_multiprocessing(self):
1239
1239
self.assert_file_count(".coverage.*", 0)
1240
1240
self.assert_exists(".coverage")
1241
1241
1242
+
def test_files_up_one_level(self):
1243
+
# https://github.com/nedbat/coveragepy/issues/1280
1244
+
self.make_file("src/mycode.py", """\
1245
+
def foo():
1246
+
return 17
1247
+
""")
1248
+
self.make_file("test/test_it.py", """\
1249
+
from src.mycode import foo
1250
+
assert foo() == 17
1251
+
""")
1252
+
self.make_file("test/.coveragerc", """\
1253
+
[run]
1254
+
parallel = True
1255
+
relative_files = True
1256
+
1257
+
[paths]
1258
+
source =
1259
+
../src/
1260
+
*/src
1261
+
""")
1262
+
os.chdir("test")
1263
+
sys.path.insert(0, "..")
1264
+
cov1 = coverage.Coverage()
1265
+
self.start_import_stop(cov1, "test_it")
1266
+
cov1.save()
1267
+
cov2 = coverage.Coverage()
1268
+
cov2.combine()
1269
+
cov3 = coverage.Coverage()
1270
+
cov3.load()
1271
+
report = self.get_report(cov3)
1272
+
assert self.last_line_squeezed(report) == "TOTAL 4 0 100%"
1273
+
1242
1274
1243
1275
class CombiningTest(CoverageTest):
1244
1276
"""More tests of combining data."""
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4