summaryrefslogtreecommitdiff
path: root/tests/test_coverage.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_coverage.py')
-rw-r--r--tests/test_coverage.py83
1 files changed, 65 insertions, 18 deletions
diff --git a/tests/test_coverage.py b/tests/test_coverage.py
index ab4faf55..ea7604b1 100644
--- a/tests/test_coverage.py
+++ b/tests/test_coverage.py
@@ -101,7 +101,7 @@ class BasicCoverageTest(CoverageTest):
# Nothing here
d = 6
""",
- [1,2,4,6], report="4 0 100%")
+ [1,2,4,6], report="4 0 0 0 100%")
def test_indentation_wackiness(self):
# Partial final lines are OK.
@@ -550,6 +550,15 @@ class SimpleStatementTest(CoverageTest):
""",
([1,3,6,7], [1,3,5,6,7], [1,3,4,5,6,7]), "")
+ def test_nonascii(self):
+ self.check_coverage("""\
+ # coding: utf8
+ a = 2
+ b = 3
+ """,
+ [2, 3]
+ )
+
class CompoundStatementTest(CoverageTest):
"""Testing coverage of multi-line compound statements."""
@@ -618,7 +627,8 @@ class CompoundStatementTest(CoverageTest):
z = 7
assert x == 3
""",
- [1,2,3,4,5,7,8], "4-7", report="7 3 57% 4-7")
+ [1,2,3,4,5,7,8], "4-7", report="7 3 4 1 45% 4-7, 2->4",
+ )
self.check_coverage("""\
a = 1; b = 2; c = 3;
if a != 1:
@@ -629,7 +639,8 @@ class CompoundStatementTest(CoverageTest):
z = 7
assert y == 5
""",
- [1,2,3,4,5,7,8], "3, 7", report="7 2 71% 3, 7")
+ [1,2,3,4,5,7,8], "3, 7", report="7 2 4 2 64% 3, 7, 2->3, 4->7",
+ )
self.check_coverage("""\
a = 1; b = 2; c = 3;
if a != 1:
@@ -640,7 +651,8 @@ class CompoundStatementTest(CoverageTest):
z = 7
assert z == 7
""",
- [1,2,3,4,5,7,8], "3, 5", report="7 2 71% 3, 5")
+ [1,2,3,4,5,7,8], "3, 5", report="7 2 4 2 64% 3, 5, 2->3, 4->5",
+ )
def test_elif_no_else(self):
self.check_coverage("""\
@@ -651,7 +663,8 @@ class CompoundStatementTest(CoverageTest):
y = 5
assert x == 3
""",
- [1,2,3,4,5,6], "4-5", report="6 2 67% 4-5")
+ [1,2,3,4,5,6], "4-5", report="6 2 4 1 50% 4-5, 2->4",
+ )
self.check_coverage("""\
a = 1; b = 2; c = 3;
if a != 1:
@@ -660,7 +673,8 @@ class CompoundStatementTest(CoverageTest):
y = 5
assert y == 5
""",
- [1,2,3,4,5,6], "3", report="6 1 83% 3")
+ [1,2,3,4,5,6], "3", report="6 1 4 2 70% 3, 2->3, 4->6",
+ )
def test_elif_bizarre(self):
self.check_coverage("""\
@@ -1008,7 +1022,10 @@ class CompoundStatementTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,4,5,7,8], "4-5")
+ [1,2,3,4,5,7,8], "4-5",
+ arcz=".1 12 23 45 58 37 78 8.",
+ arcz_missing="45 58",
+ )
self.check_coverage("""\
a = 0
try:
@@ -1020,7 +1037,10 @@ class CompoundStatementTest(CoverageTest):
a = 123
assert a == 99
""",
- [1,2,3,4,5,6,8,9], "8")
+ [1,2,3,4,5,6,8,9], "8",
+ arcz=".1 12 23 34 45 56 69 89 9.",
+ arcz_missing="89",
+ )
def test_try_finally(self):
self.check_coverage("""\
@@ -1366,7 +1386,10 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,7,8], "", excludes=['#pragma: NO COVER'])
+ [1,2,3,7,8], "", excludes=['#pragma: NO COVER'],
+ arcz=".1 12 23 37 45 58 78 8.",
+ arcz_missing="45 58",
+ )
self.check_coverage("""\
a = 0
try:
@@ -1378,7 +1401,10 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 99
""",
- [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'])
+ [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'],
+ arcz=".1 12 23 34 45 56 69 89 9.",
+ arcz_missing="89",
+ )
def test_excluding_try_except_pass(self):
self.check_coverage("""\
@@ -1412,7 +1438,10 @@ class ExcludeTest(CoverageTest):
a = 123
assert a == 123
""",
- [1,2,3,7,8], "", excludes=['#pragma: NO COVER'])
+ [1,2,3,7,8], "", excludes=['#pragma: NO COVER'],
+ arcz=".1 12 23 37 45 58 78 8.",
+ arcz_missing="45 58",
+ )
self.check_coverage("""\
a = 0
try:
@@ -1424,7 +1453,10 @@ class ExcludeTest(CoverageTest):
x = 2
assert a == 99
""",
- [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'])
+ [1,2,3,4,5,6,9], "", excludes=['#pragma: NO COVER'],
+ arcz=".1 12 23 34 45 56 69 89 9.",
+ arcz_missing="89",
+ )
def test_excluding_if_pass(self):
# From a comment on the coverage.py page by Michael McNeil Forbes:
@@ -1598,7 +1630,9 @@ class Py25Test(CoverageTest):
b = 2
assert a == 1 and b == 2
""",
- [1,2,3,4,5,7,8], "4-5")
+ [1,2,3,4,5,7,8], "4-5",
+ arcz=".1 12 23 37 45 57 78 8.", arcz_missing="45 57",
+ )
self.check_coverage("""\
a = 0; b = 0
try:
@@ -1610,7 +1644,9 @@ class Py25Test(CoverageTest):
b = 2
assert a == 99 and b == 2
""",
- [1,2,3,4,5,6,8,9], "")
+ [1,2,3,4,5,6,8,9], "",
+ arcz=".1 12 23 34 45 56 68 89 9.",
+ )
self.check_coverage("""\
a = 0; b = 0
try:
@@ -1624,7 +1660,9 @@ class Py25Test(CoverageTest):
b = 2
assert a == 123 and b == 2
""",
- [1,2,3,4,5,6,7,8,10,11], "6")
+ [1,2,3,4,5,6,7,8,10,11], "6",
+ arcz=".1 12 23 34 45 56 57 78 6A 8A AB B.", arcz_missing="56 6A",
+ )
self.check_coverage("""\
a = 0; b = 0
try:
@@ -1640,7 +1678,10 @@ class Py25Test(CoverageTest):
b = 2
assert a == 17 and b == 2
""",
- [1,2,3,4,5,6,7,8,9,10,12,13], "6, 9-10")
+ [1,2,3,4,5,6,7,8,9,10,12,13], "6, 9-10",
+ arcz=".1 12 23 34 45 56 6C 57 78 8C 79 9A AC CD D.",
+ arcz_missing="56 6C 79 9A AC",
+ )
self.check_coverage("""\
a = 0; b = 0
try:
@@ -1653,7 +1694,10 @@ class Py25Test(CoverageTest):
b = 2
assert a == 123 and b == 2
""",
- [1,2,3,4,5,7,9,10], "4-5")
+ [1,2,3,4,5,7,9,10], "4-5",
+ arcz=".1 12 23 37 45 59 79 9A A.",
+ arcz_missing="45 59",
+ )
self.check_coverage("""\
a = 0; b = 0
try:
@@ -1667,7 +1711,10 @@ class Py25Test(CoverageTest):
b = 2
assert a == 99 and b == 2
""",
- [1,2,3,4,5,6,8,10,11], "8")
+ [1,2,3,4,5,6,8,10,11], "8",
+ arcz=".1 12 23 34 45 56 6A 8A AB B.",
+ arcz_missing="8A",
+ )
class ModuleTest(CoverageTest):