summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2023-01-02 22:03:59 -0500
committerNed Batchelder <ned@nedbatchelder.com>2023-01-02 22:03:59 -0500
commit0b05b45e342813b34d906e840e253a06b37133ae (patch)
treeff38df2bfdc0faed5d1cd0d1fc42630c9e487192 /tests
parent2090f79d4a0447f4d3744ea957fcebd951f0b843 (diff)
downloadpython-coveragepy-git-0b05b45e342813b34d906e840e253a06b37133ae.tar.gz
mypy: test_annotate.py test_arcs.py test_collector.py
Diffstat (limited to 'tests')
-rw-r--r--tests/test_annotate.py12
-rw-r--r--tests/test_arcs.py188
-rw-r--r--tests/test_collector.py2
3 files changed, 101 insertions, 101 deletions
diff --git a/tests/test_annotate.py b/tests/test_annotate.py
index e2d49f25..99ce2694 100644
--- a/tests/test_annotate.py
+++ b/tests/test_annotate.py
@@ -12,7 +12,7 @@ from tests.goldtest import compare, gold_path
class AnnotationGoldTest(CoverageTest):
"""Test the annotate feature with gold files."""
- def make_multi(self):
+ def make_multi(self) -> None:
"""Make a few source files we need for the tests."""
self.make_file("multi.py", """\
import a.a
@@ -36,7 +36,7 @@ class AnnotationGoldTest(CoverageTest):
print(msg)
""")
- def test_multi(self):
+ def test_multi(self) -> None:
self.make_multi()
cov = coverage.Coverage()
self.start_import_stop(cov, "multi")
@@ -44,7 +44,7 @@ class AnnotationGoldTest(CoverageTest):
compare(gold_path("annotate/multi"), ".", "*,cover")
- def test_annotate_dir(self):
+ def test_annotate_dir(self) -> None:
self.make_multi()
cov = coverage.Coverage(source=["."])
self.start_import_stop(cov, "multi")
@@ -52,7 +52,7 @@ class AnnotationGoldTest(CoverageTest):
compare(gold_path("annotate/anno_dir"), "out_anno_dir", "*,cover")
- def test_encoding(self):
+ def test_encoding(self) -> None:
self.make_file("utf8.py", """\
# -*- coding: utf-8 -*-
# This comment has an accent: é
@@ -64,7 +64,7 @@ class AnnotationGoldTest(CoverageTest):
cov.annotate()
compare(gold_path("annotate/encodings"), ".", "*,cover")
- def test_white(self):
+ def test_white(self) -> None:
self.make_file("white.py", """\
# A test case sent to me by Steve White
@@ -106,7 +106,7 @@ class AnnotationGoldTest(CoverageTest):
cov.annotate()
compare(gold_path("annotate/white"), ".", "*,cover")
- def test_missing_after_else(self):
+ def test_missing_after_else(self) -> None:
self.make_file("mae.py", """\
def f(x):
if x == 1:
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 02592918..8232e1cf 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -26,7 +26,7 @@ xfail_pypy_3882 = pytest.mark.xfail(
class SimpleArcTest(CoverageTest):
"""Tests for coverage.py's arc measurement."""
- def test_simple_sequence(self):
+ def test_simple_sequence(self) -> None:
self.check_coverage("""\
a = 1
b = 2
@@ -49,7 +49,7 @@ class SimpleArcTest(CoverageTest):
arcz="-{0}2 23 35 5-{0}".format(line1)
)
- def test_function_def(self):
+ def test_function_def(self) -> None:
self.check_coverage("""\
def foo():
a = 2
@@ -58,7 +58,7 @@ class SimpleArcTest(CoverageTest):
""",
arcz=".1 .2 14 2. 4.")
- def test_if(self):
+ def test_if(self) -> None:
self.check_coverage("""\
a = 1
if len([]) == 0:
@@ -74,7 +74,7 @@ class SimpleArcTest(CoverageTest):
""",
arcz=".1 12 23 24 34 4.", arcz_missing="23 34")
- def test_if_else(self):
+ def test_if_else(self) -> None:
self.check_coverage("""\
if len([]) == 0:
a = 2
@@ -92,7 +92,7 @@ class SimpleArcTest(CoverageTest):
""",
arcz=".1 12 25 14 45 5.", arcz_missing="12 25")
- def test_compact_if(self):
+ def test_compact_if(self) -> None:
self.check_coverage("""\
a = 1
if len([]) == 0: a = 2
@@ -109,7 +109,7 @@ class SimpleArcTest(CoverageTest):
""",
arcz=".1 14 45 5. .2 2. 23 3.", arcz_missing="23 3.")
- def test_multiline(self):
+ def test_multiline(self) -> None:
self.check_coverage("""\
a = (
2 +
@@ -121,7 +121,7 @@ class SimpleArcTest(CoverageTest):
arcz=".1 15 5.",
)
- def test_if_return(self):
+ def test_if_return(self) -> None:
self.check_coverage("""\
def if_ret(a):
if a:
@@ -134,7 +134,7 @@ class SimpleArcTest(CoverageTest):
arcz=".1 16 67 7. .2 23 24 3. 45 5.",
)
- def test_dont_confuse_exit_and_else(self):
+ def test_dont_confuse_exit_and_else(self) -> None:
self.check_coverage("""\
def foo():
if foo:
@@ -157,7 +157,7 @@ class SimpleArcTest(CoverageTest):
arcz=".1 16 6. .2 23 3. 25 5.", arcz_missing="25 5."
)
- def test_what_is_the_sound_of_no_lines_clapping(self):
+ def test_what_is_the_sound_of_no_lines_clapping(self) -> None:
if env.PYBEHAVIOR.empty_is_empty:
arcz_missing=".1 1."
else:
@@ -169,7 +169,7 @@ class SimpleArcTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_bug_1184(self):
+ def test_bug_1184(self) -> None:
self.check_coverage("""\
def foo(x):
if x:
@@ -190,7 +190,7 @@ class SimpleArcTest(CoverageTest):
class WithTest(CoverageTest):
"""Arc-measuring tests involving context managers."""
- def test_with(self):
+ def test_with(self) -> None:
arcz = ".1 .2 23 34 4. 16 6."
if env.PYBEHAVIOR.exit_through_with:
arcz = arcz.replace("4.", "42 2.")
@@ -205,7 +205,7 @@ class WithTest(CoverageTest):
arcz=arcz,
)
- def test_with_return(self):
+ def test_with_return(self) -> None:
arcz = ".1 .2 23 34 4. 16 6."
if env.PYBEHAVIOR.exit_through_with:
arcz = arcz.replace("4.", "42 2.")
@@ -220,7 +220,7 @@ class WithTest(CoverageTest):
arcz=arcz,
)
- def test_bug_146(self):
+ def test_bug_146(self) -> None:
# https://github.com/nedbat/coveragepy/issues/146
arcz = ".1 12 23 34 41 15 5."
if env.PYBEHAVIOR.exit_through_with:
@@ -235,7 +235,7 @@ class WithTest(CoverageTest):
arcz=arcz,
)
- def test_nested_with_return(self):
+ def test_nested_with_return(self) -> None:
arcz = ".1 .2 23 34 45 56 6. 18 8."
if env.PYBEHAVIOR.exit_through_with:
arcz = arcz.replace("6.", "64 42 2.")
@@ -252,7 +252,7 @@ class WithTest(CoverageTest):
arcz=arcz,
)
- def test_break_through_with(self):
+ def test_break_through_with(self) -> None:
arcz = ".1 12 23 34 45 15 5."
if env.PYBEHAVIOR.exit_through_with:
arcz = arcz.replace("45", "42 25")
@@ -267,7 +267,7 @@ class WithTest(CoverageTest):
arcz_missing="15",
)
- def test_continue_through_with(self):
+ def test_continue_through_with(self) -> None:
arcz = ".1 12 23 34 41 15 5."
if env.PYBEHAVIOR.exit_through_with:
arcz = arcz.replace("41", "42 21")
@@ -282,7 +282,7 @@ class WithTest(CoverageTest):
)
# https://github.com/nedbat/coveragepy/issues/1270
- def test_raise_through_with(self):
+ def test_raise_through_with(self) -> None:
if env.PYBEHAVIOR.exit_through_with:
arcz = ".1 12 27 78 8. 9A A. -23 34 45 53 6-2"
arcz_missing = "6-2 8."
@@ -310,7 +310,7 @@ class WithTest(CoverageTest):
expected = "line 3 didn't jump to the function exit"
assert self.get_missing_arc_description(cov, 3, -2) == expected
- def test_untaken_raise_through_with(self):
+ def test_untaken_raise_through_with(self) -> None:
if env.PYBEHAVIOR.exit_through_with:
arcz = ".1 12 28 89 9. AB B. -23 34 45 56 53 63 37 7-2"
arcz_missing = "56 63 AB B."
@@ -340,7 +340,7 @@ class WithTest(CoverageTest):
class LoopArcTest(CoverageTest):
"""Arc-measuring tests involving loops."""
- def test_loop(self):
+ def test_loop(self) -> None:
self.check_coverage("""\
for i in range(10):
a = i
@@ -356,7 +356,7 @@ class LoopArcTest(CoverageTest):
""",
arcz=".1 12 23 32 24 4.", arcz_missing="23 32")
- def test_nested_loop(self):
+ def test_nested_loop(self) -> None:
self.check_coverage("""\
for i in range(3):
for j in range(3):
@@ -366,7 +366,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 12 23 32 21 14 4.",
)
- def test_break(self):
+ def test_break(self) -> None:
if env.PYBEHAVIOR.omit_after_jump:
arcz = ".1 12 23 35 15 5."
arcz_missing = "15"
@@ -384,7 +384,7 @@ class LoopArcTest(CoverageTest):
arcz=arcz, arcz_missing=arcz_missing
)
- def test_continue(self):
+ def test_continue(self) -> None:
if env.PYBEHAVIOR.omit_after_jump:
arcz = ".1 12 23 31 15 5."
arcz_missing = ""
@@ -402,7 +402,7 @@ class LoopArcTest(CoverageTest):
arcz=arcz, arcz_missing=arcz_missing
)
- def test_nested_breaks(self):
+ def test_nested_breaks(self) -> None:
self.check_coverage("""\
for i in range(3):
for j in range(3):
@@ -414,7 +414,7 @@ class LoopArcTest(CoverageTest):
""",
arcz=".1 12 23 34 45 25 56 51 67 17 7.", arcz_missing="17 25")
- def test_while_1(self):
+ def test_while_1(self) -> None:
# With "while 1", the loop knows it's constant.
if env.PYBEHAVIOR.keep_constant_test:
arcz = ".1 12 23 34 45 36 62 57 7."
@@ -434,7 +434,7 @@ class LoopArcTest(CoverageTest):
arcz=arcz,
)
- def test_while_true(self):
+ def test_while_true(self) -> None:
# With "while True", 2.x thinks it's computation,
# 3.x thinks it's constant.
if env.PYBEHAVIOR.keep_constant_test:
@@ -455,7 +455,7 @@ class LoopArcTest(CoverageTest):
arcz=arcz,
)
- def test_zero_coverage_while_loop(self):
+ def test_zero_coverage_while_loop(self) -> None:
# https://github.com/nedbat/coveragepy/issues/502
self.make_file("main.py", "print('done')")
self.make_file("zero.py", """\
@@ -477,7 +477,7 @@ class LoopArcTest(CoverageTest):
squeezed = self.squeezed_lines(report)
assert expected in squeezed[3]
- def test_bug_496_continue_in_constant_while(self):
+ def test_bug_496_continue_in_constant_while(self) -> None:
# https://github.com/nedbat/coveragepy/issues/496
# A continue in a while-true needs to jump to the right place.
if env.PYBEHAVIOR.keep_constant_test:
@@ -498,7 +498,7 @@ class LoopArcTest(CoverageTest):
arcz=arcz
)
- def test_for_if_else_for(self):
+ def test_for_if_else_for(self) -> None:
self.check_coverage("""\
def branches_2(l):
if l:
@@ -525,7 +525,7 @@ class LoopArcTest(CoverageTest):
arcz_missing="26 6."
)
- def test_for_else(self):
+ def test_for_else(self) -> None:
self.check_coverage("""\
def forelse(seq):
for n in seq:
@@ -540,7 +540,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 .2 23 32 34 47 26 67 7. 18 89 9."
)
- def test_while_else(self):
+ def test_while_else(self) -> None:
self.check_coverage("""\
def whileelse(seq):
while seq:
@@ -556,7 +556,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 19 9A A. .2 23 34 45 58 42 27 78 8.",
)
- def test_confusing_for_loop_bug_175(self):
+ def test_confusing_for_loop_bug_175(self) -> None:
self.check_coverage("""\
o = [(1,2), (3,4)]
o = [a for a in o]
@@ -577,7 +577,7 @@ class LoopArcTest(CoverageTest):
# https://bugs.python.org/issue44672
@pytest.mark.xfail(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
- def test_incorrect_loop_exit_bug_1175(self):
+ def test_incorrect_loop_exit_bug_1175(self) -> None:
self.check_coverage("""\
def wrong_loop(x):
if x:
@@ -594,7 +594,7 @@ class LoopArcTest(CoverageTest):
# https://bugs.python.org/issue44672
@pytest.mark.xfail(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
- def test_incorrect_if_bug_1175(self):
+ def test_incorrect_if_bug_1175(self) -> None:
self.check_coverage("""\
def wrong_loop(x):
if x:
@@ -609,7 +609,7 @@ class LoopArcTest(CoverageTest):
arcz_missing="26 3. 6.",
)
- def test_generator_expression(self):
+ def test_generator_expression(self) -> None:
# Generator expression:
self.check_coverage("""\
o = ((1,2), (3,4))
@@ -621,7 +621,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 -22 2-2 12 23 34 45 53 3.",
)
- def test_generator_expression_another_way(self):
+ def test_generator_expression_another_way(self) -> None:
# https://bugs.python.org/issue44450
# Generator expression:
self.check_coverage("""\
@@ -636,7 +636,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 -22 2-2 12 25 56 67 75 5.",
)
- def test_other_comprehensions(self):
+ def test_other_comprehensions(self) -> None:
# Set comprehension:
self.check_coverage("""\
o = ((1,2), (3,4))
@@ -658,7 +658,7 @@ class LoopArcTest(CoverageTest):
arcz=".1 -22 2-2 12 23 34 45 53 3.",
)
- def test_multiline_dict_comp(self):
+ def test_multiline_dict_comp(self) -> None:
# Multiline dict comp:
self.check_coverage("""\
# comment
@@ -700,7 +700,7 @@ class LoopArcTest(CoverageTest):
class ExceptionArcTest(CoverageTest):
"""Arc-measuring tests involving exception handling."""
- def test_try_except(self):
+ def test_try_except(self) -> None:
self.check_coverage("""\
a, b = 1, 1
try:
@@ -711,7 +711,7 @@ class ExceptionArcTest(CoverageTest):
""",
arcz=".1 12 23 36 45 56 6.", arcz_missing="45 56")
- def test_raise_followed_by_statement(self):
+ def test_raise_followed_by_statement(self) -> None:
if env.PYBEHAVIOR.omit_after_jump:
arcz = ".1 12 23 34 46 67 78 8."
arcz_missing = ""
@@ -731,7 +731,7 @@ class ExceptionArcTest(CoverageTest):
arcz=arcz, arcz_missing=arcz_missing,
)
- def test_hidden_raise(self):
+ def test_hidden_raise(self) -> None:
self.check_coverage("""\
a, b = 1, 1
def oops(x):
@@ -749,7 +749,7 @@ class ExceptionArcTest(CoverageTest):
arcz_missing="3-2 78 8B", arcz_unpredicted="79",
)
- def test_except_with_type(self):
+ def test_except_with_type(self) -> None:
self.check_coverage("""\
a, b = 1, 1
def oops(x):
@@ -771,7 +771,7 @@ class ExceptionArcTest(CoverageTest):
)
@xfail_pypy_3882
- def test_try_finally(self):
+ def test_try_finally(self) -> None:
self.check_coverage("""\
a, c = 1, 1
try:
@@ -814,7 +814,7 @@ class ExceptionArcTest(CoverageTest):
)
@xfail_pypy_3882
- def test_finally_in_loop(self):
+ def test_finally_in_loop(self) -> None:
self.check_coverage("""\
a, c, d, i = 1, 1, 1, 99
try:
@@ -854,7 +854,7 @@ class ExceptionArcTest(CoverageTest):
@xfail_pypy_3882
- def test_break_through_finally(self):
+ def test_break_through_finally(self) -> None:
arcz = ".1 12 23 34 3D 45 56 67 68 7A AD 8A A3 BC CD D."
if env.PYBEHAVIOR.finally_jumps_back:
arcz = arcz.replace("AD", "A7 7D")
@@ -877,7 +877,7 @@ class ExceptionArcTest(CoverageTest):
arcz_missing="3D BC CD",
)
- def test_break_continue_without_finally(self):
+ def test_break_continue_without_finally(self) -> None:
self.check_coverage("""\
a, c, d, i = 1, 1, 1, 99
try:
@@ -898,7 +898,7 @@ class ExceptionArcTest(CoverageTest):
)
@xfail_pypy_3882
- def test_continue_through_finally(self):
+ def test_continue_through_finally(self) -> None:
arcz = ".1 12 23 34 3D 45 56 67 68 7A 8A A3 BC CD D."
if env.PYBEHAVIOR.finally_jumps_back:
arcz += " 73 A7"
@@ -921,7 +921,7 @@ class ExceptionArcTest(CoverageTest):
arcz_missing="BC CD",
)
- def test_finally_in_loop_bug_92(self):
+ def test_finally_in_loop_bug_92(self) -> None:
self.check_coverage("""\
for i in range(5):
try:
@@ -934,7 +934,7 @@ class ExceptionArcTest(CoverageTest):
arcz=".1 12 23 35 56 61 17 7.",
)
- def test_bug_212(self):
+ def test_bug_212(self) -> None:
# "except Exception as e" is crucial here.
# Bug 212 said that the "if exc" line was incorrectly marked as only
# partially covered.
@@ -959,7 +959,7 @@ class ExceptionArcTest(CoverageTest):
arcz_unpredicted="CD",
)
- def test_except_finally(self):
+ def test_except_finally(self) -> None:
self.check_coverage("""\
a, b, c = 1, 1, 1
try:
@@ -988,7 +988,7 @@ class ExceptionArcTest(CoverageTest):
arcz=".1 12 -23 3-2 24 45 56 67 7B 89 9B BC C.",
arcz_missing="67 7B", arcz_unpredicted="68")
- def test_multiple_except_clauses(self):
+ def test_multiple_except_clauses(self) -> None:
self.check_coverage("""\
a, b, c = 1, 1, 1
try:
@@ -1056,7 +1056,7 @@ class ExceptionArcTest(CoverageTest):
arcz_unpredicted="45 7A AB",
)
- def test_return_finally(self):
+ def test_return_finally(self) -> None:
arcz = ".1 12 29 9A AB BC C-1 -23 34 45 7-2 57 38 8-2"
if env.PYBEHAVIOR.finally_jumps_back:
arcz = arcz.replace("7-2", "75 5-2")
@@ -1078,7 +1078,7 @@ class ExceptionArcTest(CoverageTest):
)
@xfail_pypy_3882
- def test_except_jump_finally(self):
+ def test_except_jump_finally(self) -> None:
arcz = (
".1 1Q QR RS ST TU U. " +
".2 23 34 45 56 4O 6L " +
@@ -1126,7 +1126,7 @@ class ExceptionArcTest(CoverageTest):
)
@xfail_pypy_3882
- def test_else_jump_finally(self):
+ def test_else_jump_finally(self) -> None:
arcz = (
".1 1S ST TU UV VW W. " +
".2 23 34 45 56 6A 78 8N 4Q " +
@@ -1179,7 +1179,7 @@ class ExceptionArcTest(CoverageTest):
class YieldTest(CoverageTest):
"""Arc tests for generators."""
- def test_yield_in_loop(self):
+ def test_yield_in_loop(self) -> None:
self.check_coverage("""\
def gen(inp):
for n in inp:
@@ -1190,7 +1190,7 @@ class YieldTest(CoverageTest):
arcz=".1 .2 23 2. 32 15 5.",
)
- def test_padded_yield_in_loop(self):
+ def test_padded_yield_in_loop(self) -> None:
self.check_coverage("""\
def gen(inp):
i = 2
@@ -1205,7 +1205,7 @@ class YieldTest(CoverageTest):
arcz=".1 19 9. .2 23 34 45 56 63 37 7.",
)
- def test_bug_308(self):
+ def test_bug_308(self) -> None:
self.check_coverage("""\
def run():
for i in range(10):
@@ -1239,7 +1239,7 @@ class YieldTest(CoverageTest):
arcz=".1 14 45 54 4. .2 2. -22 2-2",
)
- def test_bug_324(self):
+ def test_bug_324(self) -> None:
# This code is tricky: the list() call pulls all the values from gen(),
# but each of them is a generator itself that is never iterated. As a
# result, the generator expression on line 3 is never entered or run.
@@ -1257,7 +1257,7 @@ class YieldTest(CoverageTest):
arcz_missing="-33 3-3",
)
- def test_coroutines(self):
+ def test_coroutines(self) -> None:
self.check_coverage("""\
def double_inputs():
while len([1]): # avoid compiler differences
@@ -1276,7 +1276,7 @@ class YieldTest(CoverageTest):
)
assert self.stdout() == "20\n12\n"
- def test_yield_from(self):
+ def test_yield_from(self) -> None:
self.check_coverage("""\
def gen(inp):
i = 2
@@ -1291,7 +1291,7 @@ class YieldTest(CoverageTest):
arcz=".1 19 9. .2 23 34 45 56 63 37 7.",
)
- def test_abandoned_yield(self):
+ def test_abandoned_yield(self) -> None:
# https://github.com/nedbat/coveragepy/issues/440
self.check_coverage("""\
def gen():
@@ -1311,7 +1311,7 @@ class YieldTest(CoverageTest):
@pytest.mark.skipif(not env.PYBEHAVIOR.match_case, reason="Match-case is new in 3.10")
class MatchCaseTest(CoverageTest):
"""Tests of match-case."""
- def test_match_case_with_default(self):
+ def test_match_case_with_default(self) -> None:
self.check_coverage("""\
for command in ["huh", "go home", "go n"]:
match command.split():
@@ -1327,7 +1327,7 @@ class MatchCaseTest(CoverageTest):
)
assert self.stdout() == "default\nno go\ngo: n\n"
- def test_match_case_with_wildcard(self):
+ def test_match_case_with_wildcard(self) -> None:
self.check_coverage("""\
for command in ["huh", "go home", "go n"]:
match command.split():
@@ -1343,7 +1343,7 @@ class MatchCaseTest(CoverageTest):
)
assert self.stdout() == "default: ['huh']\nno go\ngo: n\n"
- def test_match_case_without_wildcard(self):
+ def test_match_case_without_wildcard(self) -> None:
self.check_coverage("""\
match = None
for command in ["huh", "go home", "go n"]:
@@ -1358,7 +1358,7 @@ class MatchCaseTest(CoverageTest):
)
assert self.stdout() == "None\nno go\ngo: n\n"
- def test_absurd_wildcard(self):
+ def test_absurd_wildcard(self) -> None:
# https://github.com/nedbat/coveragepy/issues/1421
self.check_coverage("""\
def absurd(x):
@@ -1375,7 +1375,7 @@ class MatchCaseTest(CoverageTest):
class OptimizedIfTest(CoverageTest):
"""Tests of if statements being optimized away."""
- def test_optimized_away_if_0(self):
+ def test_optimized_away_if_0(self) -> None:
if env.PYBEHAVIOR.keep_constant_test:
lines = [1, 2, 3, 4, 8, 9]
arcz = ".1 12 23 24 34 48 49 89 9."
@@ -1404,7 +1404,7 @@ class OptimizedIfTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_optimized_away_if_1(self):
+ def test_optimized_away_if_1(self) -> None:
if env.PYBEHAVIOR.keep_constant_test:
lines = [1, 2, 3, 4, 5, 6, 9]
arcz = ".1 12 23 24 34 45 49 56 69 59 9."
@@ -1433,7 +1433,7 @@ class OptimizedIfTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_optimized_away_if_1_no_else(self):
+ def test_optimized_away_if_1_no_else(self) -> None:
if env.PYBEHAVIOR.keep_constant_test:
lines = [1, 2, 3, 4, 5]
arcz = ".1 12 23 25 34 45 5."
@@ -1457,7 +1457,7 @@ class OptimizedIfTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_optimized_if_nested(self):
+ def test_optimized_if_nested(self) -> None:
if env.PYBEHAVIOR.keep_constant_test:
lines = [1, 2, 8, 11, 12, 13, 14, 15]
arcz = ".1 12 28 2F 8B 8F BC CD DE EF F."
@@ -1492,7 +1492,7 @@ class OptimizedIfTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_dunder_debug(self):
+ def test_dunder_debug(self) -> None:
# Since some of our tests use __debug__, let's make sure it is true as
# we expect
assert __debug__
@@ -1508,7 +1508,7 @@ class OptimizedIfTest(CoverageTest):
"""
)
- def test_if_debug(self):
+ def test_if_debug(self) -> None:
if env.PYBEHAVIOR.optimize_if_debug:
arcz = ".1 12 24 41 26 61 1."
arcz_missing = ""
@@ -1528,7 +1528,7 @@ class OptimizedIfTest(CoverageTest):
)
@xfail_pypy_3882
- def test_if_not_debug(self):
+ def test_if_not_debug(self) -> None:
if env.PYBEHAVIOR.optimize_if_not_debug == 1:
arcz = ".1 12 23 34 42 37 72 28 8."
elif env.PYBEHAVIOR.optimize_if_not_debug == 2:
@@ -1554,7 +1554,7 @@ class OptimizedIfTest(CoverageTest):
class MiscArcTest(CoverageTest):
"""Miscellaneous arc-measuring tests."""
- def test_dict_literal(self):
+ def test_dict_literal(self) -> None:
self.check_coverage("""\
d = {
'a': 2,
@@ -1582,7 +1582,7 @@ class MiscArcTest(CoverageTest):
arcz=".1 19 9.",
)
- def test_unpacked_literals(self):
+ def test_unpacked_literals(self) -> None:
self.check_coverage("""\
d = {
'a': 2,
@@ -1613,7 +1613,7 @@ class MiscArcTest(CoverageTest):
)
@pytest.mark.parametrize("n", [10, 50, 100, 500, 1000, 2000, 10000])
- def test_pathologically_long_code_object(self, n):
+ def test_pathologically_long_code_object(self, n: int) -> None:
# https://github.com/nedbat/coveragepy/issues/359
# Long code objects sometimes cause problems. Originally, it was
# due to EXTENDED_ARG bytes codes. Then it showed a mistake in
@@ -1632,7 +1632,7 @@ class MiscArcTest(CoverageTest):
self.check_coverage(code, arcs=[(-1, 1), (1, 2*n+4), (2*n+4, -1)])
assert self.stdout() == f"{n}\n"
- def test_partial_generators(self):
+ def test_partial_generators(self) -> None:
# https://github.com/nedbat/coveragepy/issues/475
# Line 2 is executed completely.
# Line 3 is started but not finished, because zip ends before it finishes.
@@ -1658,7 +1658,7 @@ class MiscArcTest(CoverageTest):
class DecoratorArcTest(CoverageTest):
"""Tests of arcs with decorators."""
- def test_function_decorator(self):
+ def test_function_decorator(self) -> None:
arcz = (
".1 16 67 7A AE EF F. " # main line
".2 24 4. -23 3-2 " # decorators
@@ -1687,7 +1687,7 @@ class DecoratorArcTest(CoverageTest):
)
@xfail_pypy38
- def test_class_decorator(self):
+ def test_class_decorator(self) -> None:
arcz = (
".1 16 67 6D 7A AE E. " # main line
".2 24 4. -23 3-2 " # decorators
@@ -1714,7 +1714,7 @@ class DecoratorArcTest(CoverageTest):
arcz=arcz,
)
- def test_bug_466a(self):
+ def test_bug_466a(self) -> None:
# A bad interaction between decorators and multi-line list assignments,
# believe it or not...!
arcz = ".1 1A A. 13 3. -35 58 8-3 "
@@ -1738,7 +1738,7 @@ class DecoratorArcTest(CoverageTest):
arcz=arcz,
)
- def test_bug_466b(self):
+ def test_bug_466b(self) -> None:
# A bad interaction between decorators and multi-line list assignments,
# believe it or not...!
arcz = ".1 1A A. 13 3. -35 58 8-3 "
@@ -1765,7 +1765,7 @@ class DecoratorArcTest(CoverageTest):
class LambdaArcTest(CoverageTest):
"""Tests of lambdas"""
- def test_multiline_lambda(self):
+ def test_multiline_lambda(self) -> None:
self.check_coverage("""\
fn = (lambda x:
x + 2
@@ -1789,7 +1789,7 @@ class LambdaArcTest(CoverageTest):
arcz="-22 2A A-2 2-2",
)
- def test_unused_lambdas_are_confusing_bug_90(self):
+ def test_unused_lambdas_are_confusing_bug_90(self) -> None:
self.check_coverage("""\
a = 1
fn = lambda x: x
@@ -1798,7 +1798,7 @@ class LambdaArcTest(CoverageTest):
arcz=".1 12 -22 2-2 23 3.", arcz_missing="-22 2-2",
)
- def test_raise_with_lambda_looks_like_partial_branch(self):
+ def test_raise_with_lambda_looks_like_partial_branch(self) -> None:
self.check_coverage("""\
def ouch(fn):
2/0
@@ -1819,7 +1819,7 @@ class LambdaArcTest(CoverageTest):
arcz_unpredicted="58",
)
- def test_lambda_in_dict(self):
+ def test_lambda_in_dict(self) -> None:
self.check_coverage("""\
x = 1
x = 2
@@ -1849,7 +1849,7 @@ class AsyncTest(CoverageTest):
"""Tests of the new async and await keywords in Python 3.5"""
@xfail_eventlet_670
- def test_async(self):
+ def test_async(self) -> None:
self.check_coverage("""\
import asyncio
@@ -1876,7 +1876,7 @@ class AsyncTest(CoverageTest):
assert self.stdout() == "Compute 1 + 2 ...\n1 + 2 = 3\n"
@xfail_eventlet_670
- def test_async_for(self):
+ def test_async_for(self) -> None:
self.check_coverage("""\
import asyncio
@@ -1913,7 +1913,7 @@ class AsyncTest(CoverageTest):
)
assert self.stdout() == "a\nb\nc\n.\n"
- def test_async_with(self):
+ def test_async_with(self) -> None:
if env.PYBEHAVIOR.exit_through_with:
arcz = ".1 1. .2 23 32 2."
arcz_missing = ".2 23 32 2."
@@ -1929,7 +1929,7 @@ class AsyncTest(CoverageTest):
arcz_missing=arcz_missing,
)
- def test_async_decorator(self):
+ def test_async_decorator(self) -> None:
arcz = ".1 14 4. .2 2. -46 6-4 "
if env.PYBEHAVIOR.trace_decorated_def:
arcz = arcz.replace("4.", "45 5.")
@@ -1950,7 +1950,7 @@ class AsyncTest(CoverageTest):
# https://github.com/nedbat/coveragepy/issues/1158
# https://bugs.python.org/issue44621
@pytest.mark.skipif(env.PYVERSION[:2] == (3, 9), reason="avoid a 3.9 bug: 44621")
- def test_bug_1158(self):
+ def test_bug_1158(self) -> None:
self.check_coverage("""\
import asyncio
@@ -1975,7 +1975,7 @@ class AsyncTest(CoverageTest):
# https://github.com/nedbat/coveragepy/issues/1176
# https://bugs.python.org/issue44622
@xfail_eventlet_670
- def test_bug_1176(self):
+ def test_bug_1176(self) -> None:
self.check_coverage("""\
import asyncio
@@ -1993,7 +1993,7 @@ class AsyncTest(CoverageTest):
assert self.stdout() == "12\n"
# https://github.com/nedbat/coveragepy/issues/1205
- def test_bug_1205(self):
+ def test_bug_1205(self) -> None:
self.check_coverage("""\
def func():
if T(2):
@@ -2017,7 +2017,7 @@ class AsyncTest(CoverageTest):
class AnnotationTest(CoverageTest):
"""Tests using type annotations."""
- def test_annotations(self):
+ def test_annotations(self) -> None:
self.check_coverage("""\
def f(x:str, y:int) -> str:
a:int = 2
@@ -2032,7 +2032,7 @@ class AnnotationTest(CoverageTest):
class ExcludeTest(CoverageTest):
"""Tests of exclusions to indicate known partial branches."""
- def test_default(self):
+ def test_default(self) -> None:
# A number of forms of pragma comment are accepted.
self.check_coverage("""\
a = 1
@@ -2049,7 +2049,7 @@ class ExcludeTest(CoverageTest):
arcz=".1 12 23 24 34 45 56 57 67 78 89 9. 8.",
)
- def test_custom_pragmas(self):
+ def test_custom_pragmas(self) -> None:
self.check_coverage("""\
a = 1
while a: # [only some]
@@ -2066,7 +2066,7 @@ class ExcludeTest(CoverageTest):
class LineDataTest(CoverageTest):
"""Tests that line_data gives us what we expect."""
- def test_branch(self):
+ def test_branch(self) -> None:
cov = coverage.Coverage(branch=True)
self.make_file("fun1.py", """\
diff --git a/tests/test_collector.py b/tests/test_collector.py
index 53d7f175..0d0c8dfe 100644
--- a/tests/test_collector.py
+++ b/tests/test_collector.py
@@ -14,7 +14,7 @@ from tests.helpers import CheckUniqueFilenames
class CollectorTest(CoverageTest):
"""Test specific aspects of the collection process."""
- def test_should_trace_cache(self):
+ def test_should_trace_cache(self) -> None:
# The tracers should only invoke should_trace once for each file name.
# Make some files that invoke each other.