diff --git a/tests/test_annotate.py b/tests/test_annotate.py index e2d49f251..99ce2694f 100644 --- a/tests/test_annotate.py +++ b/tests/test_annotate.py @@ -12,7 +12,7 @@ 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 @@ def b(x): 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 @@ def test_multi(self): 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 @@ def test_annotate_dir(self): 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 @@ def test_encoding(self): 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 @@ def h(x): 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 025929183..8232e1cf9 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -26,7 +26,7 @@ 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 @@ def test_simple_sequence(self): 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 @@ def foo(): """, 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 @@ def test_if(self): """, 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 @@ def test_if_else(self): """, 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 @@ def fn(x): """, 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 @@ def test_multiline(self): 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 @@ def if_ret(a): 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 @@ def foo(): 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 @@ def test_what_is_the_sound_of_no_lines_clapping(self): 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 @@ def foo(x): 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 @@ def example(): 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 @@ def example(): 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 @@ def test_bug_146(self): 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 @@ def example(x): 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 @@ def test_break_through_with(self): 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 @@ def test_continue_through_with(self): ) # 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 @@ def f(x): 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 @@ def f(x): 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 @@ def test_loop(self): """, 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 @@ def test_nested_loop(self): 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 @@ def test_break(self): 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 @@ def test_continue(self): 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 @@ def test_nested_breaks(self): """, 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 @@ def test_while_1(self): 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 @@ def test_while_true(self): 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 @@ def method(self): 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 @@ def test_bug_496_continue_in_constant_while(self): 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 @@ def branches_3(l): 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 @@ def forelse(seq): 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 @@ def whileelse(seq): 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 @@ def test_confusing_for_loop_bug_175(self): # 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 @@ def wrong_loop(x): # 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 @@ def wrong_loop(x): 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 @@ def test_generator_expression(self): 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 @@ def test_generator_expression_another_way(self): 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 @@ def test_other_comprehensions(self): 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 @@ def test_multiline_dict_comp(self): 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 @@ def test_try_except(self): """, 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 @@ def test_raise_followed_by_statement(self): 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 @@ def oops(x): 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 @@ def try_it(x): ) @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 @@ def test_try_finally(self): ) @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 @@ def test_finally_in_loop(self): @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 @@ def test_break_through_finally(self): 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 @@ def test_break_continue_without_finally(self): ) @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 @@ def test_continue_through_finally(self): 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 @@ def test_finally_in_loop_bug_92(self): 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 @@ def b(exc): 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 @@ def oops(x): 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 @@ def test_multiple_except_clauses(self): 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 @@ def check_token(data): ) @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 @@ def func(x): ) @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 @@ def func(x): 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 @@ def gen(inp): 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 @@ def gen(inp): 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 @@ def run(): 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 @@ def gen(inp): 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 @@ def double_inputs(): ) 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 @@ def gen(inp): 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 @@ def gen(): @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 @@ def test_match_case_with_default(self): ) 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 @@ def test_match_case_with_wildcard(self): ) 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 @@ def test_match_case_without_wildcard(self): ) 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 @@ def absurd(x): 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 @@ def test_optimized_away_if_0(self): 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 @@ def test_optimized_away_if_1(self): 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 @@ def test_optimized_away_if_1_no_else(self): 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 @@ def test_optimized_if_nested(self): 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 @@ def test_dunder_debug(self): """ ) - 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 @@ def test_if_debug(self): ) @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 @@ def test_if_not_debug(self): 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 @@ def test_dict_literal(self): 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 @@ def test_unpacked_literals(self): ) @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 @@ def test_pathologically_long_code_object(self, n): 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 @@ def f(a, b): 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 @@ def my_function( ) @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 MyObject( 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 @@ def parse(cls): 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 @@ def parse(cls): 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 @@ def test_multiline_lambda(self): 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 @@ def test_unused_lambdas_are_confusing_bug_90(self): 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 @@ def ouch(fn): 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 @@ async def print_sum(x, y): # 8 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 @@ async def doit(): # G ) 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 @@ async def go(): 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 @@ async def go(): # 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 @@ async def async_test(): # 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 @@ async def async_test(): 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 @@ def func(): 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 @@ def f(x:str, y:int) -> str: 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 @@ def test_default(self): 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 @@ def test_custom_pragmas(self): 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 53d7f1752..0d0c8dfe8 100644 --- a/tests/test_collector.py +++ b/tests/test_collector.py @@ -14,7 +14,7 @@ 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. diff --git a/tox.ini b/tox.ini index 2d632adbc..a5cf258cb 100644 --- a/tox.ini +++ b/tox.ini @@ -101,7 +101,7 @@ setenv = C_FN=coverage/files.py coverage/inorout.py coverage/jsonreport.py coverage/lcovreport.py coverage/multiproc.py coverage/numbits.py C_OP=coverage/parser.py coverage/phystokens.py coverage/plugin.py coverage/plugin_support.py coverage/python.py C_QZ=coverage/report.py coverage/results.py coverage/sqldata.py coverage/tomlconfig.py coverage/types.py coverage/version.py coverage/xmlreport.py - T_AN=tests/test_api.py tests/test_cmdline.py tests/goldtest.py tests/helpers.py tests/test_html.py tests/test_xml.py + T_AN=tests/test_annotate.py tests/test_api.py tests/test_arcs.py tests/test_cmdline.py tests/test_collector.py tests/goldtest.py tests/helpers.py tests/test_html.py tests/test_xml.py TYPEABLE={env:C__B} {env:C_CC} {env:C_DE} {env:C_FN} {env:C_OP} {env:C_QZ} {env:T_AN} commands =