Skip to content

Commit

Permalink
Gate assignment expr parentheses removal tests to 3.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
xrisk committed Feb 23, 2021
1 parent 84f7ba6 commit 7415d1c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 10 additions & 0 deletions tests/data/pep_572_remove_parens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if (foo := 0):
pass

y = (x := 0)

# output
if foo := 0:
pass

y = (x := 0)
9 changes: 0 additions & 9 deletions tests/data/remove_parens.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def example7():
def example8():
return (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((None)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

def example9():
if (foo := 0):
pass

# output
x = 1
x = 1.2
Expand Down Expand Up @@ -144,8 +140,3 @@ def example7():

def example8():
return None


def example9():
if foo := 0:
pass
9 changes: 9 additions & 0 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ def test_pep_572(self) -> None:
if sys.version_info >= (3, 8):
black.assert_equivalent(source, actual)

@patch("black.dump_to_file", dump_to_stderr)
def test_pep_572_remove_parens(self) -> None:
source, expected = read_data("pep_572_remove_parens")
actual = fs(source)
self.assertFormatEqual(expected, actual)
black.assert_stable(source, actual, DEFAULT_MODE)
if sys.version_info >= (3, 8):
black.assert_equivalent(source, actual)

def test_pep_572_version_detection(self) -> None:
source, _ = read_data("pep_572")
root = black.lib2to3_parse(source)
Expand Down

0 comments on commit 7415d1c

Please sign in to comment.