summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-12-31 07:48:43 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-12-31 07:48:43 -0500
commita9bc9bfd1179a64839d4908fb8f54e7823ee044e (patch)
tree122d598cd31bc034a011c7ffa6c4928d2d036237 /tests
parent372f411b8ca76f85c0cc6cc4415d5bee2ca948e2 (diff)
downloadpython-coveragepy-git-a9bc9bfd1179a64839d4908fb8f54e7823ee044e.tar.gz
Easier to decipher arcz output
Diffstat (limited to 'tests')
-rw-r--r--tests/coveragetest.py6
-rw-r--r--tests/test_misc.py21
2 files changed, 23 insertions, 4 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 1917c5b3..905d6098 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -26,7 +26,7 @@ from coverage import env
from coverage.backunittest import TestCase, unittest
from coverage.backward import StringIO, import_local_file, string_class, shlex_quote
from coverage.cmdline import CoverageScript
-from coverage.misc import arcz_to_arcs, StopEverything
+from coverage.misc import arcs_to_arcz_repr, arcz_to_arcs, StopEverything
from tests.helpers import run_command, SuperModuleCleaner
@@ -140,8 +140,8 @@ class CoverageTest(
def assert_equal_arcs(self, a1, a2, msg=None):
"""Assert that the arc lists `a1` and `a2` are equal."""
# Make them into multi-line strings so we can see what's going wrong.
- s1 = "\n".join(repr(a) for a in a1) + "\n"
- s2 = "\n".join(repr(a) for a in a2) + "\n"
+ s1 = arcs_to_arcz_repr(a1)
+ s2 = arcs_to_arcz_repr(a2)
self.assertMultiLineEqual(s1, s2, msg)
def check_coverage(
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 896dbf47..e6b83236 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -5,7 +5,8 @@
import pytest
-from coverage.misc import arcz_to_arcs, contract, dummy_decorator_with_args, file_be_gone
+from coverage.misc import arcs_to_arcz_repr, arcz_to_arcs
+from coverage.misc import contract, dummy_decorator_with_args, file_be_gone
from coverage.misc import Hasher, one_of, substitute_variables
from coverage.misc import CoverageException, USE_CONTRACTS
@@ -167,3 +168,21 @@ def test_substitute_variables_errors(text):
])
def test_arcz_to_arcs(arcz, arcs):
assert arcz_to_arcs(arcz) == arcs
+
+
+@pytest.mark.parametrize("arcs, arcz_repr", [
+ ([(-1, 1), (1, 2), (2, -1)], "(-1, 1) # .1\n(1, 2) # 12\n(2, -1) # 2.\n"),
+ ([(-1, 1), (1, 2), (2, -5)], "(-1, 1) # .1\n(1, 2) # 12\n(2, -5) # 2-5\n"),
+ ([(-26, 10), (12, 11), (18, 29), (35, -10), (1, 33), (100, 7)],
+ (
+ "(-26, 10) # -QA\n"
+ "(12, 11) # CB\n"
+ "(18, 29) # IT\n"
+ "(35, -10) # Z-A\n"
+ "(1, 33) # 1X\n"
+ "(100, 7) # ?7\n"
+ )
+ ),
+])
+def test_arcs_to_arcz_repr(arcs, arcz_repr):
+ assert arcs_to_arcz_repr(arcs) == arcz_repr