summaryrefslogtreecommitdiff
path: root/tests/test_html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-10-12 19:37:58 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-10-13 12:30:25 -0400
commiteba18707241a052419d54cdc304aea346aa0605c (patch)
tree2e8a9c1391aa7d293bebacf5ea86169319eafda9 /tests/test_html.py
parentbcbdf41c6bb9d4ee30842bd14d45c7d48c2c6d01 (diff)
downloadpython-coveragepy-git-eba18707241a052419d54cdc304aea346aa0605c.tar.gz
Better presentation of contexts. #855
Diffstat (limited to 'tests/test_html.py')
-rw-r--r--tests/test_html.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_html.py b/tests/test_html.py
index 29f81a05..c9f82062 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -1038,6 +1038,8 @@ assert len(math) == 18
class HtmlWithContextsTest(HtmlTestHelpers, CoverageTest):
"""Tests of the HTML reports with shown contexts."""
+ EMPTY = coverage.html.HtmlDataGeneration.EMPTY
+
def html_data_from_cov(self, cov, morf):
"""Get HTML report data from a `Coverage` object for a morf."""
with self.assert_warnings(cov, []):
@@ -1083,11 +1085,15 @@ class HtmlWithContextsTest(HtmlTestHelpers, CoverageTest):
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 = ['(empty)', 'two_tests.test_one', 'two_tests.test_two']
+ from coverage.debug import pp
+ pp(d)
+ 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 in (ld.contexts or ())]
+ actual = [
+ ld.number for ld in d.lines
+ if label == ld.contexts_label or label in (ld.contexts or ())
+ ]
assert sorted(expected) == sorted(actual)
def test_filtered_dynamic_contexts(self):
@@ -1099,7 +1105,7 @@ class HtmlWithContextsTest(HtmlTestHelpers, CoverageTest):
mod = self.start_import_stop(cov, "two_tests")
d = self.html_data_from_cov(cov, mod)
- context_labels = ['(empty)', 'two_tests.test_one', 'two_tests.test_two']
+ context_labels = [self.EMPTY, 'two_tests.test_one', 'two_tests.test_two']
expected_lines = [[], self.TEST_ONE_LINES, []]
for label, expected in zip(context_labels, expected_lines):
actual = [ld.number for ld in d.lines if label in (ld.contexts or ())]