summaryrefslogtreecommitdiff
path: root/tests/test_data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-10 12:06:19 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-10 12:06:19 -0400
commit6c5ef77a267e244f4e50a161bd6bcf09831de943 (patch)
tree8342253e6c7740c8acead47ba0a4aa85c4f886be /tests/test_data.py
parente54b7576a35b3dd4642788cff557a2ccebf7582b (diff)
downloadpython-coveragepy-git-6c5ef77a267e244f4e50a161bd6bcf09831de943.tar.gz
test: test two add_file_tracer possibilities
Diffstat (limited to 'tests/test_data.py')
-rw-r--r--tests/test_data.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_data.py b/tests/test_data.py
index a1689ad6..3adba5f0 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -296,9 +296,31 @@ class CoverageDataTest(CoverageTest):
})
covdata.add_file_tracers({"p1.foo": "p1.plugin", "p2.html": "p2.plugin"})
assert covdata.file_tracer("p1.foo") == "p1.plugin"
+ assert covdata.file_tracer("p2.html") == "p2.plugin"
assert covdata.file_tracer("main.py") == ""
assert covdata.file_tracer("p3.not_here") is None
+ def test_ok_to_repeat_file_tracer(self):
+ covdata = DebugCoverageData()
+ covdata.add_lines({
+ "p1.foo": dict.fromkeys([1, 2, 3]),
+ "p2.html": dict.fromkeys([10, 11, 12]),
+ })
+ covdata.add_file_tracers({"p1.foo": "p1.plugin", "p2.html": "p2.plugin"})
+ covdata.add_file_tracers({"p1.foo": "p1.plugin"})
+ assert covdata.file_tracer("p1.foo") == "p1.plugin"
+
+ def test_ok_to_set_empty_file_tracer(self):
+ covdata = DebugCoverageData()
+ covdata.add_lines({
+ "p1.foo": dict.fromkeys([1, 2, 3]),
+ "p2.html": dict.fromkeys([10, 11, 12]),
+ "main.py": dict.fromkeys([20]),
+ })
+ covdata.add_file_tracers({"p1.foo": "p1.plugin", "main.py": ""})
+ assert covdata.file_tracer("p1.foo") == "p1.plugin"
+ assert covdata.file_tracer("main.py") == ""
+
def test_cant_file_tracer_unmeasured_files(self):
covdata = DebugCoverageData()
msg = "Can't add file tracer data for unmeasured file 'p1.foo'"