Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Jan 25, 2022
1 parent a4242a9 commit 010c6c6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 41 deletions.
12 changes: 12 additions & 0 deletions tests/data/trailing_comma_optional_parens1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
if e1234123412341234.winerror not in (_winapi.ERROR_SEM_TIMEOUT,
_winapi.ERROR_PIPE_BUSY) or _check_timeout(t):
pass

# output

if (
e1234123412341234.winerror
not in (
_winapi.ERROR_SEM_TIMEOUT,
_winapi.ERROR_PIPE_BUSY,
)
or _check_timeout(t)
):
pass
16 changes: 15 additions & 1 deletion tests/data/trailing_comma_optional_parens2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
if (e123456.get_tk_patchlevel() >= (8, 6, 0, 'final') or
(8, 5, 8) <= get_tk_patchlevel() < (8, 6)):
pass
pass

# output

if (
e123456.get_tk_patchlevel() >= (8, 6, 0, "final")
or (
8,
5,
8,
)
<= get_tk_patchlevel()
< (8, 6)
):
pass
18 changes: 17 additions & 1 deletion tests/data/trailing_comma_optional_parens3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
+ "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
) % {"reported_username": reported_username, "report_reason": report_reason}
) % {"reported_username": reported_username, "report_reason": report_reason}


# output


if True:
if True:
if True:
return _(
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweas "
+ "qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwegqweasdzxcqweasdzxc.",
"qweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqweasdzxcqwe",
) % {
"reported_username": reported_username,
"report_reason": report_reason,
}
39 changes: 0 additions & 39 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,45 +228,6 @@ def _test_wip(self) -> None:
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, black.FileMode())

@unittest.expectedFailure
@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability1(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens1")
actual = fs(source)
black.assert_stable(source, actual, DEFAULT_MODE)

@unittest.expectedFailure
@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability2(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens2")
actual = fs(source)
black.assert_stable(source, actual, DEFAULT_MODE)

@unittest.expectedFailure
@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability3(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens3")
actual = fs(source)
black.assert_stable(source, actual, DEFAULT_MODE)

@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability1_pass2(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens1")
actual = fs(fs(source)) # this is what `format_file_contents` does with --safe
black.assert_stable(source, actual, DEFAULT_MODE)

@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability2_pass2(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens2")
actual = fs(fs(source)) # this is what `format_file_contents` does with --safe
black.assert_stable(source, actual, DEFAULT_MODE)

@patch("black.dump_to_file", dump_to_stderr)
def test_trailing_comma_optional_parens_stability3_pass2(self) -> None:
source, _expected = read_data("trailing_comma_optional_parens3")
actual = fs(fs(source)) # this is what `format_file_contents` does with --safe
black.assert_stable(source, actual, DEFAULT_MODE)

def test_pep_572_version_detection(self) -> None:
source, _ = read_data("pep_572")
root = black.lib2to3_parse(source)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"remove_parens",
"slices",
"string_prefixes",
"trailing_comma_optional_parens1",
"trailing_comma_optional_parens2",
"trailing_comma_optional_parens3",
"tricky_unicode_symbols",
"tupleassign",
]
Expand Down

0 comments on commit 010c6c6

Please sign in to comment.