summaryrefslogtreecommitdiff
path: root/tests/test_data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-09 16:41:59 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-09 16:41:59 -0400
commit498b1484e466588a22cef520095f1fd0ed8b8ff8 (patch)
tree84979ae5f419d8632ba898d8464dc142778e9f1c /tests/test_data.py
parent4d55ada1bdca638b0fd12e887fb0faaa574dee8d (diff)
downloadpython-coveragepy-git-498b1484e466588a22cef520095f1fd0ed8b8ff8.tar.gz
fix: contexts_by_lineno now returns a true dict
Diffstat (limited to 'tests/test_data.py')
-rw-r--r--tests/test_data.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index 2d3f164c..80cd9bc2 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -206,7 +206,8 @@ class CoverageDataTest(DataTestHelpers, CoverageTest):
covdata = CoverageData()
covdata.set_context('test_a')
covdata.add_lines(LINES_1)
- assert covdata.contexts_by_lineno('a.py') == {1: ['test_a'], 2: ['test_a']}
+ expected = {1: ['test_a'], 2: ['test_a']}
+ assert covdata.contexts_by_lineno('a.py') == expected
@pytest.mark.parametrize("lines", [LINES_1, dicts_from_sets(LINES_1)])
def test_no_duplicate_lines(self, lines):
@@ -249,13 +250,33 @@ class CoverageDataTest(DataTestHelpers, CoverageTest):
covdata = CoverageData()
covdata.set_context('test_x')
covdata.add_arcs(ARCS_3)
- expected = {-1: ['test_x'], 1: ['test_x'], 2: ['test_x'], 3: ['test_x']}
- assert expected == covdata.contexts_by_lineno('x.py')
+ expected = {1: ['test_x'], 2: ['test_x'], 3: ['test_x']}
+ assert covdata.contexts_by_lineno('x.py') == expected
def test_contexts_by_lineno_with_unknown_file(self):
covdata = CoverageData()
+ covdata.set_context('test_x')
+ covdata.add_arcs(ARCS_3)
assert covdata.contexts_by_lineno('xyz.py') == {}
+ def test_context_by_lineno_with_query_contexts_with_lines(self):
+ covdata = CoverageData()
+ covdata.set_context("test_1")
+ covdata.add_lines(LINES_1)
+ covdata.set_context("test_2")
+ covdata.add_lines(LINES_2)
+ covdata.set_query_context("test_1")
+ assert covdata.contexts_by_lineno("a.py") == dict.fromkeys([1,2], ["test_1"])
+
+ def test_context_by_lineno_with_query_contexts_with_arcs(self):
+ covdata = CoverageData()
+ covdata.set_context("test_1")
+ covdata.add_arcs(ARCS_3)
+ covdata.set_context("test_2")
+ covdata.add_arcs(ARCS_4)
+ covdata.set_query_context("test_1")
+ assert covdata.contexts_by_lineno("x.py") == dict.fromkeys([1,2,3], ["test_1"])
+
def test_file_tracer_name(self):
covdata = CoverageData()
covdata.add_lines({