Skip to content

Commit 7684c38

Browse files
committed
Added failing test for source with trailing slash
This test is nearly identical to the one above it, with the only change being the source that is used. This may end up turning into a fixture instead if the tests end up being identical after the fix is made.
1 parent 3a476c3 commit 7684c38

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/test_xml.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_accented_directory(self) -> None:
320320

321321
def test_no_duplicate_packages(self) -> None:
322322
self.make_file(
323-
"namespace/package/__init__.py",
323+
"namespace/package/__init__.py",
324324
"from . import sample; from . import test; from .subpackage import test"
325325
)
326326
self.make_file("namespace/package/sample.py", "print('package.sample')")
@@ -489,6 +489,19 @@ def test_relative_source(self) -> None:
489489
elts = dom.findall(".//sources/source")
490490
assert [elt.text for elt in elts] == ["src"]
491491

492+
def test_relative_source_trailing_slash(self) -> None:
493+
self.make_file("src/mod.py", "print(17)")
494+
cov = coverage.Coverage(source=["src/"])
495+
cov.set_option("run:relative_files", True)
496+
self.start_import_stop(cov, "mod", modfile="src/mod.py")
497+
cov.xml_report()
498+
499+
with open("coverage.xml") as x:
500+
print(x.read())
501+
dom = ElementTree.parse("coverage.xml")
502+
elts = dom.findall(".//sources/source")
503+
assert [elt.text for elt in elts] == ["src"]
504+
492505

493506
def compare_xml(expected: str, actual: str, actual_extra: bool = False) -> None:
494507
"""Specialized compare function for our XML files."""

0 commit comments

Comments
 (0)