summaryrefslogtreecommitdiff
path: root/tests/test_html.py
diff options
context:
space:
mode:
authorDavid Szotten <davidszotten@gmail.com>2019-12-20 16:03:09 +0000
committerNed Batchelder <ned@nedbatchelder.com>2019-12-21 10:28:40 -0500
commitade1f2c534d1b85c8b465ce302ab345b316ec3ef (patch)
tree427add523f3760d6eba40b67e7f5e93dda0c8a26 /tests/test_html.py
parent7dc37728d3ddddd12115bb94c58ad0dc67dcfb3e (diff)
downloadpython-coveragepy-git-ade1f2c534d1b85c8b465ce302ab345b316ec3ef.tar.gz
fix context reporting for relative_files
fix reporting of contexts when `relative_files = True` fixes #900
Diffstat (limited to 'tests/test_html.py')
-rw-r--r--tests/test_html.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_html.py b/tests/test_html.py
index 6c4c706c..b543fa08 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -1127,3 +1127,20 @@ class HtmlWithContextsTest(HtmlTestHelpers, CoverageTest):
self.start_import_stop(cov, "two_tests")
with self.assert_warnings(cov, ["No contexts were measured"]):
cov.html_report()
+
+ def test_dynamic_contexts_relative_files(self):
+ self.make_file("two_tests.py", self.SOURCE)
+ self.make_file("config", "[run]\nrelative_files = True")
+ cov = coverage.Coverage(source=["."], config_file="config")
+ cov.set_option("run:dynamic_context", "test_function")
+ cov.set_option("html:show_contexts", True)
+ mod = self.start_import_stop(cov, "two_tests")
+ d = self.html_data_from_cov(cov, mod)
+ context_labels = [self.EMPTY, 'two_tests.test_one', 'two_tests.test_two']
+ expected_lines = [self.OUTER_LINES, self.TEST_ONE_LINES, self.TEST_TWO_LINES]
+ for label, expected in zip(context_labels, expected_lines):
+ actual = [
+ ld.number for ld in d.lines
+ if label == ld.contexts_label or label in (ld.contexts or ())
+ ]
+ assert sorted(expected) == sorted(actual)