From 5d0b5d4464b84adb6389c8894c207a323edb2b2b Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 2 Dec 2023 15:17:19 -0500 Subject: [PATCH] style: check_coverage close parens should be on their own line --- tests/test_arcs.py | 41 +++-- tests/test_coverage.py | 354 ++++++++++++++++++++++++++--------------- tests/test_oddball.py | 9 +- 3 files changed, 262 insertions(+), 142 deletions(-) diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 497585afa..7331eb32a 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -32,13 +32,15 @@ def test_simple_sequence(self) -> None: a = 1 b = 2 """, - arcz=".1 12 2.") + arcz=".1 12 2." + ) self.check_coverage("""\ a = 1 b = 3 """, - arcz=".1 13 3.") + arcz=".1 13 3." + ) line1 = 1 if env.PYBEHAVIOR.module_firstline_1 else 2 self.check_coverage("""\ @@ -57,7 +59,8 @@ def foo(): foo() """, - arcz=".1 .2 14 2. 4.") + arcz=".1 .2 14 2. 4." + ) def test_if(self) -> None: self.check_coverage("""\ @@ -66,14 +69,16 @@ def test_if(self) -> None: a = 3 assert a == 3 """, - arcz=".1 12 23 24 34 4.", arcz_missing="24") + arcz=".1 12 23 24 34 4.", arcz_missing="24" + ) self.check_coverage("""\ a = 1 if len([]) == 1: a = 3 assert a == 1 """, - arcz=".1 12 23 24 34 4.", arcz_missing="23 34") + arcz=".1 12 23 24 34 4.", arcz_missing="23 34" + ) def test_if_else(self) -> None: self.check_coverage("""\ @@ -83,7 +88,8 @@ def test_if_else(self) -> None: a = 4 assert a == 2 """, - arcz=".1 12 25 14 45 5.", arcz_missing="14 45") + arcz=".1 12 25 14 45 5.", arcz_missing="14 45" + ) self.check_coverage("""\ if len([]) == 1: a = 2 @@ -91,7 +97,8 @@ def test_if_else(self) -> None: a = 4 assert a == 4 """, - arcz=".1 12 25 14 45 5.", arcz_missing="12 25") + arcz=".1 12 25 14 45 5.", arcz_missing="12 25" + ) def test_compact_if(self) -> None: self.check_coverage("""\ @@ -108,7 +115,8 @@ def fn(x): a = fn(1) assert a is True """, - arcz=".1 14 45 5. .2 2. 23 3.", arcz_missing="23 3.") + arcz=".1 14 45 5. .2 2. 23 3.", arcz_missing="23 3." + ) def test_multiline(self) -> None: self.check_coverage("""\ @@ -355,7 +363,8 @@ def test_loop(self) -> None: a = i assert a == -1 """, - arcz=".1 12 23 32 24 4.", arcz_missing="23 32") + arcz=".1 12 23 32 24 4.", arcz_missing="23 32" + ) def test_nested_loop(self) -> None: self.check_coverage("""\ @@ -413,7 +422,8 @@ def test_nested_breaks(self) -> None: break assert a == 2 and i == 2 # 7 """, - arcz=".1 12 23 34 45 25 56 51 67 17 7.", arcz_missing="17 25") + arcz=".1 12 23 34 45 25 56 51 67 17 7.", arcz_missing="17 25" + ) def test_while_1(self) -> None: # With "while 1", the loop knows it's constant. @@ -714,7 +724,8 @@ def test_try_except(self) -> None: b = 5 assert a == 3 and b == 1 """, - arcz=".1 12 23 36 45 56 6.", arcz_missing="45 56") + arcz=".1 12 23 36 45 56 6.", arcz_missing="45 56" + ) def test_raise_followed_by_statement(self) -> None: if env.PYBEHAVIOR.omit_after_jump: @@ -975,7 +986,8 @@ def test_except_finally(self) -> None: c = 7 assert a == 3 and b == 1 and c == 7 """, - arcz=".1 12 23 45 37 57 78 8.", arcz_missing="45 57") + arcz=".1 12 23 45 37 57 78 8.", arcz_missing="45 57" + ) self.check_coverage("""\ a, b, c = 1, 1, 1 def oops(x): @@ -991,7 +1003,8 @@ def oops(x): assert a == 5 and b == 9 and c == 11 """, arcz=".1 12 -23 3-2 24 45 56 67 7B 89 9B BC C.", - arcz_missing="67 7B", arcz_unpredicted="68") + arcz_missing="67 7B", arcz_unpredicted="68" + ) def test_multiple_except_clauses(self) -> None: self.check_coverage("""\ @@ -1221,7 +1234,6 @@ def run(): """, arcz=".1 15 56 65 5. .2 23 32 2. -33 3-3", ) - self.check_coverage("""\ def run(): yield lambda: 100 @@ -1233,7 +1245,6 @@ def run(): """, arcz=".1 16 67 76 6. .2 23 34 43 3. -22 2-2 -44 4-4", ) - self.check_coverage("""\ def run(): yield lambda: 100 # no branch miss diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 928c1bd66..1bbb22ac7 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -121,7 +121,8 @@ def test_simple(self) -> None: # Nothing here d = 6 """, - [1,2,4,6], report="4 0 0 0 100%") + [1,2,4,6], report="4 0 0 0 100%" + ) def test_indentation_wackiness(self) -> None: # Partial final lines are OK. @@ -130,7 +131,8 @@ def test_indentation_wackiness(self) -> None: if not sys.path: a = 1 """, # indented last line - [1,2,3], "3") + [1,2,3], "3" + ) def test_multiline_initializer(self) -> None: self.check_coverage("""\ @@ -142,7 +144,8 @@ def test_multiline_initializer(self) -> None: e = { 'foo': 1, 'bar': 2 } """, - [1,7], "") + [1,7], "" + ) def test_list_comprehension(self) -> None: self.check_coverage("""\ @@ -152,7 +155,8 @@ def test_list_comprehension(self) -> None: ] assert l == [12, 14, 16, 18] """, - [1,5], "") + [1,5], "" + ) class SimpleStatementTest(CoverageTest): @@ -166,26 +170,30 @@ def test_expression(self) -> None: 12 23 """, - ([1,2],[2]), "") + ([1,2],[2]), "" + ) self.check_coverage("""\ 12 23 a = 3 """, - ([1,2,3],[3]), "") + ([1,2,3],[3]), "" + ) self.check_coverage("""\ 1 + 2 1 + \\ 2 """, - ([1,2], [2]), "") + ([1,2], [2]), "" + ) self.check_coverage("""\ 1 + 2 1 + \\ 2 a = 4 """, - ([1,2,4], [4]), "") + ([1,2,4], [4]), "" + ) def test_assert(self) -> None: self.check_coverage("""\ @@ -197,7 +205,8 @@ def test_assert(self) -> None: 2), \\ 'something is amiss' """, - [1,2,4,5], "") + [1,2,4,5], "" + ) def test_assignment(self) -> None: # Simple variable assignment @@ -208,7 +217,8 @@ def test_assignment(self) -> None: c = \\ 1 """, - [1,2,4], "") + [1,2,4], "" + ) def test_assign_tuple(self) -> None: self.check_coverage("""\ @@ -216,7 +226,8 @@ def test_assign_tuple(self) -> None: a,b,c = 7,8,9 assert a == 7 and b == 8 and c == 9 """, - [1,2,3], "") + [1,2,3], "" + ) def test_more_assignments(self) -> None: self.check_coverage("""\ @@ -231,7 +242,8 @@ def test_more_assignments(self) -> None: ] = \\ 9 """, - [1, 2, 3], "") + [1, 2, 3], "" + ) def test_attribute_assignment(self) -> None: # Attribute assignment @@ -244,7 +256,8 @@ class obj: pass o.foo = \\ 1 """, - [1,2,3,4,6], "") + [1,2,3,4,6], "" + ) def test_list_of_attribute_assignment(self) -> None: self.check_coverage("""\ @@ -258,7 +271,8 @@ class obj: pass 1, \\ 2 """, - [1,2,3,4,7], "") + [1,2,3,4,7], "" + ) def test_augmented_assignment(self) -> None: self.check_coverage("""\ @@ -269,7 +283,8 @@ def test_augmented_assignment(self) -> None: a += \\ 1 """, - [1,2,3,5], "") + [1,2,3,5], "" + ) def test_triple_string_stuff(self) -> None: self.check_coverage("""\ @@ -291,7 +306,8 @@ def test_triple_string_stuff(self) -> None: lines. ''') """, - [1,5,11], "") + [1,5,11], "" + ) def test_pass(self) -> None: # pass is tricky: if it's the only statement in a block, then it is @@ -300,27 +316,31 @@ def test_pass(self) -> None: if 1==1: pass """, - [1,2], "") + [1,2], "" + ) self.check_coverage("""\ def foo(): pass foo() """, - [1,2,3], "") + [1,2,3], "" + ) self.check_coverage("""\ def foo(): "doc" pass foo() """, - ([1,3,4], [1,4]), "") + ([1,3,4], [1,4]), "" + ) self.check_coverage("""\ class Foo: def foo(self): pass Foo().foo() """, - [1,2,3,4], "") + [1,2,3,4], "" + ) self.check_coverage("""\ class Foo: def foo(self): @@ -328,7 +348,8 @@ def foo(self): pass Foo().foo() """, - ([1,2,4,5], [1,2,5]), "") + ([1,2,4,5], [1,2,5]), "" + ) def test_del(self) -> None: self.check_coverage("""\ @@ -342,7 +363,8 @@ def test_del(self) -> None: d['e'] assert(len(d.keys()) == 0) """, - [1,2,3,6,9], "") + [1,2,3,6,9], "" + ) def test_raise(self) -> None: self.check_coverage("""\ @@ -353,7 +375,8 @@ def test_raise(self) -> None: except: pass """, - [1,2,5,6], "") + [1,2,5,6], "" + ) def test_raise_followed_by_statement(self) -> None: if env.PYBEHAVIOR.omit_after_jump: @@ -369,7 +392,8 @@ def test_raise_followed_by_statement(self) -> None: except: pass """, - lines=lines, missing=missing) + lines=lines, missing=missing + ) def test_return(self) -> None: self.check_coverage("""\ @@ -380,7 +404,8 @@ def fn(): x = fn() assert(x == 1) """, - [1,2,3,5,6], "") + [1,2,3,5,6], "" + ) self.check_coverage("""\ def fn(): a = 1 @@ -391,7 +416,8 @@ def fn(): x = fn() assert(x == 2) """, - [1,2,3,7,8], "") + [1,2,3,7,8], "" + ) self.check_coverage("""\ def fn(): a = 1 @@ -402,7 +428,8 @@ def fn(): x,y,z = fn() assert x == 1 and y == 2 and z == 3 """, - [1,2,3,7,8], "") + [1,2,3,7,8], "" + ) def test_return_followed_by_statement(self) -> None: if env.PYBEHAVIOR.omit_after_return: @@ -435,7 +462,8 @@ def gen(): a,b,c = gen() assert a == 1 and b == 9 and c == (1,2) """, - [1,2,3,6,8,9], "") + [1,2,3,6,8,9], "" + ) def test_break(self) -> None: if env.PYBEHAVIOR.omit_after_jump: @@ -452,7 +480,8 @@ def test_break(self) -> None: a = 4 assert a == 2 """, - lines=lines, missing=missing) + lines=lines, missing=missing + ) def test_continue(self) -> None: if env.PYBEHAVIOR.omit_after_jump: @@ -469,7 +498,8 @@ def test_continue(self) -> None: a = 4 assert a == 11 """, - lines=lines, missing=missing) + lines=lines, missing=missing + ) def test_strange_unexecuted_continue(self) -> None: # Peephole optimization of jumps to jumps can mean that some statements @@ -508,14 +538,16 @@ def test_import(self) -> None: from sys import path a = 1 """, - [1,2,3], "") + [1,2,3], "" + ) self.check_coverage("""\ import string if 1 == 2: from sys import path a = 1 """, - [1,2,3,4], "3") + [1,2,3,4], "3" + ) self.check_coverage("""\ import string, \\ os, \\ @@ -524,30 +556,35 @@ def test_import(self) -> None: stdout a = 1 """, - [1,4,6], "") + [1,4,6], "" + ) self.check_coverage("""\ import sys, sys as s assert s.path == sys.path """, - [1,2], "") + [1,2], "" + ) self.check_coverage("""\ import sys, \\ sys as s assert s.path == sys.path """, - [1,3], "") + [1,3], "" + ) self.check_coverage("""\ from sys import path, \\ path as p assert p == path """, - [1,3], "") + [1,3], "" + ) self.check_coverage("""\ from sys import \\ * assert len(path) > 0 """, - [1,3], "") + [1,3], "" + ) def test_global(self) -> None: self.check_coverage("""\ @@ -560,7 +597,8 @@ def fn(): fn() assert g == 2 and h == 2 and i == 2 """, - [1,2,6,7,8], "") + [1,2,6,7,8], "" + ) self.check_coverage("""\ g = h = i = 1 def fn(): @@ -568,7 +606,8 @@ def fn(): fn() assert g == 2 and h == 1 and i == 1 """, - [1,2,3,4,5], "") + [1,2,3,4,5], "" + ) def test_exec(self) -> None: self.check_coverage("""\ @@ -579,7 +618,8 @@ def test_exec(self) -> None: "2") assert a == 2 and b == 2 and c == 2 """, - [1,2,3,6], "") + [1,2,3,6], "" + ) self.check_coverage("""\ vars = {'a': 1, 'b': 1, 'c': 1} exec("a = 2", vars) @@ -588,7 +628,8 @@ def test_exec(self) -> None: "2", vars) assert vars['a'] == 2 and vars['b'] == 2 and vars['c'] == 2 """, - [1,2,3,6], "") + [1,2,3,6], "" + ) self.check_coverage("""\ globs = {} locs = {'a': 1, 'b': 1, 'c': 1} @@ -598,7 +639,8 @@ def test_exec(self) -> None: "2", globs, locs) assert locs['a'] == 2 and locs['b'] == 2 and locs['c'] == 2 """, - [1,2,3,4,7], "") + [1,2,3,4,7], "" + ) def test_extra_doc_string(self) -> None: self.check_coverage("""\ @@ -662,7 +704,8 @@ def test_statement_list(self) -> None: assert (a,b,c,d,e) == (1,2,3,4,5) """, - [1,2,3,5], "") + [1,2,3,5], "" + ) def test_if(self) -> None: self.check_coverage("""\ @@ -675,7 +718,8 @@ def test_if(self) -> None: x = 7 assert x == 7 """, - [1,2,3,4,5,7,8], "") + [1,2,3,4,5,7,8], "" + ) self.check_coverage("""\ a = 1 if a == 1: @@ -684,7 +728,8 @@ def test_if(self) -> None: y = 5 assert x == 3 """, - [1,2,3,5,6], "5") + [1,2,3,5,6], "5" + ) self.check_coverage("""\ a = 1 if a != 1: @@ -693,7 +738,8 @@ def test_if(self) -> None: y = 5 assert y == 5 """, - [1,2,3,5,6], "3") + [1,2,3,5,6], "3" + ) self.check_coverage("""\ a = 1; b = 2 if a == 1: @@ -705,7 +751,8 @@ def test_if(self) -> None: z = 8 assert x == 4 """, - [1,2,3,4,6,8,9], "6-8") + [1,2,3,4,6,8,9], "6-8" + ) def test_elif(self) -> None: self.check_coverage("""\ @@ -783,7 +830,8 @@ def f(self): else: x = 13 """, - [1,2,3,4,5,6,7,8,9,10,11,13], "2-13") + [1,2,3,4,5,6,7,8,9,10,11,13], "2-13" + ) def test_split_if(self) -> None: self.check_coverage("""\ @@ -798,7 +846,8 @@ def test_split_if(self) -> None: z = 7 assert x == 3 """, - [1,2,4,5,7,9,10], "5-9") + [1,2,4,5,7,9,10], "5-9" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if \\ @@ -811,7 +860,8 @@ def test_split_if(self) -> None: z = 7 assert y == 5 """, - [1,2,4,5,7,9,10], "4, 9") + [1,2,4,5,7,9,10], "4, 9" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if \\ @@ -824,7 +874,8 @@ def test_split_if(self) -> None: z = 7 assert z == 7 """, - [1,2,4,5,7,9,10], "4, 7") + [1,2,4,5,7,9,10], "4, 7" + ) def test_pathological_split_if(self) -> None: self.check_coverage("""\ @@ -841,7 +892,8 @@ def test_pathological_split_if(self) -> None: z = 7 assert x == 3 """, - [1,2,5,6,9,11,12], "6-11") + [1,2,5,6,9,11,12], "6-11" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if ( @@ -856,7 +908,8 @@ def test_pathological_split_if(self) -> None: z = 7 assert y == 5 """, - [1,2,5,6,9,11,12], "5, 11") + [1,2,5,6,9,11,12], "5, 11" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if ( @@ -871,7 +924,8 @@ def test_pathological_split_if(self) -> None: z = 7 assert z == 7 """, - [1,2,5,6,9,11,12], "5, 9") + [1,2,5,6,9,11,12], "5, 9" + ) def test_absurd_split_if(self) -> None: self.check_coverage("""\ @@ -886,7 +940,8 @@ def test_absurd_split_if(self) -> None: z = 7 assert x == 3 """, - [1,2,4,5,7,9,10], "5-9") + [1,2,4,5,7,9,10], "5-9" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if a != 1 \\ @@ -899,7 +954,8 @@ def test_absurd_split_if(self) -> None: z = 7 assert y == 5 """, - [1,2,4,5,7,9,10], "4, 9") + [1,2,4,5,7,9,10], "4, 9" + ) self.check_coverage("""\ a = 1; b = 2; c = 3; if a != 1 \\ @@ -912,7 +968,8 @@ def test_absurd_split_if(self) -> None: z = 7 assert z == 7 """, - [1,2,4,5,7,9,10], "4, 7") + [1,2,4,5,7,9,10], "4, 7" + ) def test_constant_if(self) -> None: if env.PYBEHAVIOR.keep_constant_test: @@ -936,7 +993,8 @@ def test_while(self) -> None: a -= 1 assert a == 0 and b == 3 """, - [1,2,3,4,5], "") + [1,2,3,4,5], "" + ) self.check_coverage("""\ a = 3; b = 0 while a: @@ -944,7 +1002,8 @@ def test_while(self) -> None: break assert a == 3 and b == 1 """, - [1,2,3,4,5], "") + [1,2,3,4,5], "" + ) def test_while_else(self) -> None: # Take the else branch. @@ -957,7 +1016,8 @@ def test_while_else(self) -> None: b = 99 assert a == 0 and b == 99 """, - [1,2,3,4,6,7], "") + [1,2,3,4,6,7], "" + ) # Don't take the else branch. self.check_coverage("""\ a = 3; b = 0 @@ -969,7 +1029,8 @@ def test_while_else(self) -> None: b = 99 assert a == 2 and b == 1 """, - [1,2,3,4,5,7,8], "7") + [1,2,3,4,5,7,8], "7" + ) def test_split_while(self) -> None: self.check_coverage("""\ @@ -980,7 +1041,8 @@ def test_split_while(self) -> None: a -= 1 assert a == 0 and b == 3 """, - [1,2,4,5,6], "") + [1,2,4,5,6], "" + ) self.check_coverage("""\ a = 3; b = 0 while ( @@ -990,7 +1052,8 @@ def test_split_while(self) -> None: a -= 1 assert a == 0 and b == 3 """, - [1,2,5,6,7], "") + [1,2,5,6,7], "" + ) def test_for(self) -> None: self.check_coverage("""\ @@ -999,7 +1062,8 @@ def test_for(self) -> None: a += i assert a == 15 """, - [1,2,3,4], "") + [1,2,3,4], "" + ) self.check_coverage("""\ a = 0 for i in [1, @@ -1008,7 +1072,8 @@ def test_for(self) -> None: a += i assert a == 15 """, - [1,2,5,6], "") + [1,2,5,6], "" + ) self.check_coverage("""\ a = 0 for i in [1,2,3,4,5]: @@ -1016,7 +1081,8 @@ def test_for(self) -> None: break assert a == 1 """, - [1,2,3,4,5], "") + [1,2,3,4,5], "" + ) def test_for_else(self) -> None: self.check_coverage("""\ @@ -1027,7 +1093,8 @@ def test_for_else(self) -> None: a = 99 assert a == 99 """, - [1,2,3,5,6], "") + [1,2,3,5,6], "" + ) self.check_coverage("""\ a = 0 for i in range(5): @@ -1037,7 +1104,8 @@ def test_for_else(self) -> None: a = 123 assert a == 1 """, - [1,2,3,4,6,7], "6") + [1,2,3,4,6,7], "6" + ) def test_split_for(self) -> None: self.check_coverage("""\ @@ -1047,7 +1115,8 @@ def test_split_for(self) -> None: a += i assert a == 15 """, - [1,2,4,5], "") + [1,2,4,5], "" + ) self.check_coverage("""\ a = 0 for \\ @@ -1057,7 +1126,8 @@ def test_split_for(self) -> None: a += i assert a == 15 """, - [1,2,6,7], "") + [1,2,6,7], "" + ) def test_try_except(self) -> None: self.check_coverage("""\ @@ -1068,7 +1138,8 @@ def test_try_except(self) -> None: a = 99 assert a == 1 """, - [1,2,3,4,5,6], "4-5") + [1,2,3,4,5,6], "4-5" + ) self.check_coverage("""\ a = 0 try: @@ -1078,7 +1149,8 @@ def test_try_except(self) -> None: a = 99 assert a == 99 """, - [1,2,3,4,5,6,7], "") + [1,2,3,4,5,6,7], "" + ) self.check_coverage("""\ a = 0 try: @@ -1090,7 +1162,8 @@ def test_try_except(self) -> None: a = 123 assert a == 123 """, - [1,2,3,4,5,6,7,8,9], "6") + [1,2,3,4,5,6,7,8,9], "6" + ) self.check_coverage("""\ a = 0 try: @@ -1104,7 +1177,8 @@ def test_try_except(self) -> None: a = 123 assert a == 17 """, - [1,2,3,4,5,6,7,8,9,10,11], "6, 9-10") + [1,2,3,4,5,6,7,8,9,10,11], "6, 9-10" + ) self.check_coverage("""\ a = 0 try: @@ -1158,7 +1232,8 @@ def test_try_finally(self) -> None: a = 99 assert a == 99 """, - [1,2,3,5,6], "") + [1,2,3,5,6], "" + ) self.check_coverage("""\ a = 0; b = 0 try: @@ -1171,7 +1246,8 @@ def test_try_finally(self) -> None: a = 99 assert a == 99 and b == 123 """, - [1,2,3,4,5,7,8,9,10], "") + [1,2,3,4,5,7,8,9,10], "" + ) def test_function_def(self) -> None: self.check_coverage("""\ @@ -1184,7 +1260,8 @@ def foo(): a = foo() assert a == 1 """, - [1,2,5,7,8], "") + [1,2,5,7,8], "" + ) self.check_coverage("""\ def foo( a, @@ -1197,7 +1274,8 @@ def foo( x = foo(17, 23) assert x == 40 """, - [1,7,9,10], "") + [1,7,9,10], "" + ) self.check_coverage("""\ def foo( a = (lambda x: x*2)(10), @@ -1213,7 +1291,8 @@ def foo( x = foo() assert x == 22 """, - [1,10,12,13], "") + [1,10,12,13], "" + ) def test_class_def(self) -> None: arcz="-22 2D DE E-2 23 36 6A A-2 -68 8-6 -AB B-A" @@ -1262,7 +1341,8 @@ def test_simple(self) -> None: if len([]): a = 4 # -cc """, - [1,3], "", excludes=['-cc']) + [1,3], "", excludes=['-cc'] + ) def test_two_excludes(self) -> None: self.check_coverage("""\ @@ -1274,7 +1354,8 @@ def test_two_excludes(self) -> None: c = 6 # -xx assert a == 1 and b == 2 """, - [1,3,5,7], "5", excludes=['-cc', '-xx']) + [1,3,5,7], "5", excludes=['-cc', '-xx'] + ) def test_excluding_if_suite(self) -> None: self.check_coverage("""\ @@ -1286,7 +1367,8 @@ def test_excluding_if_suite(self) -> None: c = 6 assert a == 1 and b == 2 """, - [1,7], "", excludes=['not-here']) + [1,7], "", excludes=['not-here'] + ) def test_excluding_if_but_not_else_suite(self) -> None: self.check_coverage("""\ @@ -1301,7 +1383,8 @@ def test_excluding_if_but_not_else_suite(self) -> None: b = 9 assert a == 8 and b == 9 """, - [1,8,9,10], "", excludes=['not-here']) + [1,8,9,10], "", excludes=['not-here'] + ) def test_excluding_else_suite(self) -> None: self.check_coverage("""\ @@ -1316,7 +1399,8 @@ def test_excluding_else_suite(self) -> None: b = 9 assert a == 4 and b == 5 and c == 6 """, - [1,3,4,5,6,10], "", excludes=['#pragma: NO COVER']) + [1,3,4,5,6,10], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 1; b = 2 @@ -1336,7 +1420,8 @@ def test_excluding_else_suite(self) -> None: b = 9 assert a == 4 and b == 5 and c == 6 """, - [1,3,4,5,6,17], "", excludes=['#pragma: NO COVER']) + [1,3,4,5,6,17], "", excludes=['#pragma: NO COVER'] + ) def test_excluding_elif_suites(self) -> None: self.check_coverage("""\ @@ -1354,7 +1439,8 @@ def test_excluding_elif_suites(self) -> None: b = 12 assert a == 4 and b == 5 and c == 6 """, - [1,3,4,5,6,11,12,13], "11-12", excludes=['#pragma: NO COVER']) + [1,3,4,5,6,11,12,13], "11-12", excludes=['#pragma: NO COVER'] + ) def test_excluding_oneline_if(self) -> None: self.check_coverage("""\ @@ -1365,7 +1451,8 @@ def foo(): foo() """, - [1,2,4,6], "", excludes=["no cover"]) + [1,2,4,6], "", excludes=["no cover"] + ) def test_excluding_a_colon_not_a_suite(self) -> None: self.check_coverage("""\ @@ -1376,7 +1463,8 @@ def foo(): foo() """, - [1,2,4,6], "", excludes=["no cover"]) + [1,2,4,6], "", excludes=["no cover"] + ) def test_excluding_for_suite(self) -> None: self.check_coverage("""\ @@ -1385,7 +1473,8 @@ def test_excluding_for_suite(self) -> None: a += i assert a == 15 """, - [1,4], "", excludes=['#pragma: NO COVER']) + [1,4], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 for i in [1, @@ -1394,7 +1483,8 @@ def test_excluding_for_suite(self) -> None: a += i assert a == 15 """, - [1,6], "", excludes=['#pragma: NO COVER']) + [1,6], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 for i in [1,2,3,4,5 @@ -1404,7 +1494,8 @@ def test_excluding_for_suite(self) -> None: a = 99 assert a == 1 """, - [1,7], "", excludes=['#pragma: NO COVER']) + [1,7], "", excludes=['#pragma: NO COVER'] + ) def test_excluding_for_else(self) -> None: self.check_coverage("""\ @@ -1416,7 +1507,8 @@ def test_excluding_for_else(self) -> None: a = 123 assert a == 1 """, - [1,2,3,4,7], "", excludes=['#pragma: NO COVER']) + [1,2,3,4,7], "", excludes=['#pragma: NO COVER'] + ) def test_excluding_while(self) -> None: self.check_coverage("""\ @@ -1426,7 +1518,8 @@ def test_excluding_while(self) -> None: break assert a == 3 and b == 0 """, - [1,5], "", excludes=['#pragma: NO COVER']) + [1,5], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 3; b = 0 while ( @@ -1436,7 +1529,8 @@ def test_excluding_while(self) -> None: break assert a == 3 and b == 0 """, - [1,7], "", excludes=['#pragma: NO COVER']) + [1,7], "", excludes=['#pragma: NO COVER'] + ) def test_excluding_while_else(self) -> None: self.check_coverage("""\ @@ -1448,7 +1542,8 @@ def test_excluding_while_else(self) -> None: b = 123 assert a == 3 and b == 1 """, - [1,2,3,4,7], "", excludes=['#pragma: NO COVER']) + [1,2,3,4,7], "", excludes=['#pragma: NO COVER'] + ) def test_excluding_try_except(self) -> None: self.check_coverage("""\ @@ -1459,7 +1554,8 @@ def test_excluding_try_except(self) -> None: a = 99 assert a == 1 """, - [1,2,3,6], "", excludes=['#pragma: NO COVER']) + [1,2,3,6], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 try: @@ -1469,7 +1565,8 @@ def test_excluding_try_except(self) -> None: a = 99 assert a == 99 """, - [1,2,3,4,5,6,7], "", excludes=['#pragma: NO COVER']) + [1,2,3,4,5,6,7], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 try: @@ -1481,7 +1578,8 @@ def test_excluding_try_except(self) -> None: a = 123 assert a == 123 """, - [1,2,3,4,7,8,9], "", excludes=['#pragma: NO COVER']) + [1,2,3,4,7,8,9], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 try: @@ -1532,7 +1630,8 @@ def f(): f() """, - [1,7], "", excludes=["no cover"]) + [1,7], "", excludes=["no cover"] + ) def test_excluding_function(self) -> None: self.check_coverage("""\ @@ -1544,8 +1643,8 @@ def fn(foo): #pragma: NO COVER x = 1 assert x == 1 """, - [6,7], "", excludes=['#pragma: NO COVER']) - + [6,7], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ a = 0 def very_long_function_to_exclude_name(very_long_argument1, @@ -1553,8 +1652,8 @@ def very_long_function_to_exclude_name(very_long_argument1, pass assert a == 0 """, - [1,5], "", excludes=['function_to_exclude']) - + [1,5], "", excludes=['function_to_exclude'] + ) self.check_coverage("""\ a = 0 def very_long_function_to_exclude_name( @@ -1564,8 +1663,8 @@ def very_long_function_to_exclude_name( pass assert a == 0 """, - [1,7], "", excludes=['function_to_exclude']) - + [1,7], "", excludes=['function_to_exclude'] + ) self.check_coverage("""\ def my_func( super_long_input_argument_0=0, @@ -1576,8 +1675,8 @@ def my_func( def my_func_2(super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [], "", excludes=['my_func']) - + [], "", excludes=['my_func'] + ) self.check_coverage("""\ def my_func( super_long_input_argument_0=0, @@ -1588,8 +1687,8 @@ def my_func( def my_func_2(super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [1,5], "5", excludes=['my_func_2']) - + [1,5], "5", excludes=['my_func_2'] + ) self.check_coverage("""\ def my_func ( super_long_input_argument_0=0, @@ -1600,8 +1699,8 @@ def my_func ( def my_func_2 (super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [1,5], "5", excludes=['my_func_2']) - + [1,5], "5", excludes=['my_func_2'] + ) self.check_coverage("""\ def my_func ( super_long_input_argument_0=0, @@ -1612,8 +1711,8 @@ def my_func ( def my_func_2 (super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [], "5", excludes=['my_func']) - + [], "5", excludes=['my_func'] + ) self.check_coverage("""\ def my_func \ ( @@ -1625,8 +1724,8 @@ def my_func \ def my_func_2(super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [1,5], "5", excludes=['my_func_2']) - + [1,5], "5", excludes=['my_func_2'] + ) self.check_coverage("""\ def my_func \ ( @@ -1638,7 +1737,8 @@ def my_func \ def my_func_2(super_long_input_argument_0=0, super_long_input_argument_1=1, super_long_input_argument_2=2): pass """, - [], "5", excludes=['my_func']) + [], "5", excludes=['my_func'] + ) def test_excluding_method(self) -> None: self.check_coverage("""\ @@ -1652,8 +1752,8 @@ def foo(self): #pragma: NO COVER x = Fooey() assert x.a == 1 """, - [1,2,3,8,9], "", excludes=['#pragma: NO COVER']) - + [1,2,3,8,9], "", excludes=['#pragma: NO COVER'] + ) self.check_coverage("""\ class Fooey: def __init__(self): @@ -1668,7 +1768,8 @@ def very_long_method_to_exclude_name( x = Fooey() assert x.a == 1 """, - [1,2,3,11,12], "", excludes=['method_to_exclude']) + [1,2,3,11,12], "", excludes=['method_to_exclude'] + ) def test_excluding_class(self) -> None: self.check_coverage("""\ @@ -1682,7 +1783,8 @@ def foo(self): x = 1 assert x == 1 """, - [8,9], "", excludes=['#pragma: NO COVER']) + [8,9], "", excludes=['#pragma: NO COVER'] + ) def test_excludes_non_ascii(self) -> None: self.check_coverage("""\ @@ -1745,7 +1847,8 @@ def p1(arg): assert p1(10) == 20 """, - lines, "") + lines, "" + ) def test_function_decorators_with_args(self) -> None: lines = [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] @@ -1763,7 +1866,8 @@ def boosted(arg): assert boosted(10) == 200 """, - lines, "") + lines, "" + ) def test_double_function_decorators(self) -> None: lines = [1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 19, 21, 22, 23, 24, 26] @@ -1795,7 +1899,8 @@ def boosted2(arg): assert boosted2(10) == 200 """, - lines, "") + lines, "" + ) class Py25Test(CoverageTest): @@ -1822,7 +1927,8 @@ def __exit__(self, type, value, tb): except: desc = "caught" """, - [1,2,3,5,6,8,9,10,11,13,14,15,16,17,18], "") + [1,2,3,5,6,8,9,10,11,13,14,15,16,17,18], "" + ) def test_try_except_finally(self) -> None: self.check_coverage("""\ diff --git a/tests/test_oddball.py b/tests/test_oddball.py index e132d5aac..390c588d4 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -44,7 +44,8 @@ def neverCalled(): fromMainThread() other.join() """, - [1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 15], "10") + [1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 15], "10" + ) def test_thread_run(self) -> None: self.check_coverage("""\ @@ -63,7 +64,8 @@ def do_work(self): thd.start() thd.join() """, - [1, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14], "") + [1, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14], "" + ) class RecursionTest(CoverageTest): @@ -81,7 +83,8 @@ def recur(n): recur(495) # We can get at least this many stack frames. i = 8 # and this line will be traced """, - [1, 2, 3, 5, 7, 8], "") + [1, 2, 3, 5, 7, 8], "" + ) def test_long_recursion(self) -> None: # We can't finish a very deep recursion, but we don't crash.