summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-01-02 13:30:03 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-01-02 13:30:03 -0500
commit4c9503ebb4ba59bb107c447b07e326127905ef57 (patch)
tree5cb744829946e2fb7f7aea617d6dc6d44790d010
parent279d71b0068a26c5c5233f057beef2967194b596 (diff)
downloadpython-coveragepy-4c9503ebb4ba59bb107c447b07e326127905ef57.tar.gz
Add tests for short_id, and pytest-ize an existing one
-rw-r--r--tests/test_debug.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/test_debug.py b/tests/test_debug.py
index 2d553ee..1961b00 100644
--- a/tests/test_debug.py
+++ b/tests/test_debug.py
@@ -6,9 +6,11 @@
import os
import re
+import pytest
+
import coverage
from coverage.backward import StringIO
-from coverage.debug import info_formatter, info_header, short_stack
+from coverage.debug import info_formatter, info_header, short_id, short_stack
from tests.coveragetest import CoverageTest
@@ -39,15 +41,23 @@ class InfoFormatterTest(CoverageTest):
lines = list(info_formatter(('info%d' % i, i) for i in range(3)))
self.assertEqual(lines, ['info0: 0', 'info1: 1', 'info2: 2'])
- def test_info_header(self):
- self.assertEqual(
- info_header("x"),
- "-- x ---------------------------------------------------------"
- )
- self.assertEqual(
- info_header("hello there"),
- "-- hello there -----------------------------------------------"
- )
+
+@pytest.mark.parametrize("label, header", [
+ ("x", "-- x ---------------------------------------------------------"),
+ ("hello there", "-- hello there -----------------------------------------------"),
+])
+def test_info_header(label, header):
+ assert info_header(label) == header
+
+
+@pytest.mark.parametrize("id64, id16", [
+ (0x1234, 0x1234),
+ (0x12340000, 0x1234),
+ (0xA5A55A5A, 0xFFFF),
+ (0x1234cba956780fed, 0x8008),
+])
+def test_short_id(id64, id16):
+ assert short_id(id64) == id16
class DebugTraceTest(CoverageTest):