Skip to content

Commit

Permalink
style: check_coverage close parens should be on their own line
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Dec 2, 2023
1 parent ac184ab commit 5d0b5d4
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 142 deletions.
41 changes: 26 additions & 15 deletions tests/test_arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("""\
Expand All @@ -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("""\
Expand All @@ -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("""\
Expand All @@ -83,15 +88,17 @@ 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
else:
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("""\
Expand All @@ -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("""\
Expand Down Expand Up @@ -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("""\
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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("""\
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 5d0b5d4

Please sign in to comment.