Skip to content

Commit

Permalink
More tests on edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Jun 21, 2021
1 parent aef8362 commit 2c750f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def some():
return x[0], y, z
"""

correct_example24 = """
def some():
x = 1
return -x
"""

# Wrong:

wrong_example1 = """
Expand Down Expand Up @@ -375,6 +381,7 @@ def test_wrong_return_variable(
correct_example21,
correct_example22,
correct_example23,
correct_example24,
])
def test_correct_return_statements(
assert_errors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
b = temp
"""

wrong_double_swap = """
dx, dy = dy, dx
dx, dy = dy, dx
"""


@pytest.mark.parametrize('code', [
wrong_swapped_variables,
wrong_swapped_variables_with_temp,
wrong_double_swap,
])
def test_wrong_swapped_variables(
assert_errors,
Expand Down
1 change: 0 additions & 1 deletion wemake_python_styleguide/visitors/ast/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def _almost_swapped(self, assigns: Sequence[ast.Assign]) -> None:

if len(previous_var & current_var) == 1:
current_var ^= previous_var

previous_var = current_var

def _check_useless_node(
Expand Down

0 comments on commit 2c750f9

Please sign in to comment.