summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-12-31 16:38:02 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-12-31 16:38:02 -0500
commit0bcb2cb8344eb4cec24455fa421ece185eec0fac (patch)
tree4d6ed7c2be8689c39b7ac949905c4883392d3a0b /coverage/data.py
parentbf73b37080c3c6deec969a555b45b70ee6727b13 (diff)
downloadpython-coveragepy-git-0bcb2cb8344eb4cec24455fa421ece185eec0fac.tar.gz
test: a sorted_lines helper
Diffstat (limited to 'coverage/data.py')
-rw-r--r--coverage/data.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/coverage/data.py b/coverage/data.py
index 986e3197..16fb9a8a 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -56,7 +56,7 @@ def add_data_to_hash(data: CoverageData, filename: str, hasher: Hasher) -> None:
if data.has_arcs():
hasher.update(sorted(data.arcs(filename) or []))
else:
- hasher.update(sorted(data.lines(filename) or []))
+ hasher.update(sorted_lines(data, filename))
hasher.update(data.file_tracer(filename))
@@ -200,3 +200,9 @@ def debug_data_file(filename: str) -> None:
if plugin:
line += f" [{plugin}]"
print(line)
+
+
+def sorted_lines(data: CoverageData, filename: str) -> List[int]:
+ """Get the sorted lines for a file, for tests."""
+ lines = data.lines(filename)
+ return sorted(lines or [])