summaryrefslogtreecommitdiff
path: root/tests/test_misc.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-02-03 07:29:59 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-02-03 07:29:59 -0500
commit839055cfd98d32c541ac2c074fb0cf6341909d26 (patch)
tree6e271a1e24bc74fddf890228befd192b6827131c /tests/test_misc.py
parent093bd6e9949770455768a403162f86d54ce31544 (diff)
downloadpython-coveragepy-git-839055cfd98d32c541ac2c074fb0cf6341909d26.tar.gz
Fiddle with, and test, format_lines
Diffstat (limited to 'tests/test_misc.py')
-rw-r--r--tests/test_misc.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_misc.py b/tests/test_misc.py
index be6d110e..939b1c98 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -5,7 +5,8 @@
import pytest
-from coverage.misc import contract, dummy_decorator_with_args, file_be_gone, Hasher, one_of
+from coverage.misc import contract, dummy_decorator_with_args, file_be_gone
+from coverage.misc import format_lines, Hasher, one_of
from tests.coveragetest import CoverageTest
@@ -114,3 +115,16 @@ class ContractTest(CoverageTest):
assert undecorated(17) == (17, None)
assert undecorated(b=23) == (None, 23)
assert undecorated(b=42, a=3) == (3, 42)
+
+
+@pytest.mark.parametrize("statements, lines, result", [
+ (set([1,2,3,4,5,10,11,12,13,14]), set([1,2,5,10,11,13,14]), "1-2, 5-11, 13-14"),
+ ([1,2,3,4,5,10,11,12,13,14,98,99], [1,2,5,10,11,13,14,99], "1-2, 5-11, 13-14, 99"),
+ ([1,2,3,4,98,99,100,101,102,103,104], [1,2,99,102,103,104], "1-2, 99, 102-104"),
+ ([17], [17], "17"),
+ ([90,91,92,93,94,95], [90,91,92,93,94,95], "90-95"),
+ ([1, 2, 3, 4, 5], [], ""),
+ ([1, 2, 3, 4, 5], [4], "4"),
+])
+def test_format_lines(statements, lines, result):
+ assert format_lines(statements, lines) == result