-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #506 #526
Merged
Merged
Issue #506 #526
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e70465f
Update noqa.py
SizovIgor a8b73a8
Add files via upload
SizovIgor c284633
Delete out.log
SizovIgor e142dc6
Add files via upload
SizovIgor 335394b
Add files via upload
SizovIgor c2a27dd
Add files via upload
SizovIgor 0a348c6
Add files via upload
SizovIgor c4f6af8
Add files via upload
SizovIgor 6f73c9a
Add tests for Z465
SizovIgor 28b95a7
Add files via upload
SizovIgor acf0087
Add files via upload
SizovIgor 05652a8
Add files via upload
SizovIgor 2bd6c22
Add files via upload
SizovIgor f30aca8
Update best_practices.py
SizovIgor 2c44772
Update noqa.py
SizovIgor 2edd46c
Update test_multiline_conditions.py
SizovIgor cfbd83c
Update test_noqa.py
SizovIgor f8c2c76
Update noqa.py
SizovIgor 940e16c
Update test_multiline_conditions.py
SizovIgor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
tests/test_visitors/test_ast/test_conditions/test_multiline_conditions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
|
||
from wemake_python_styleguide.violations.best_practices import ( | ||
MultilineConditionsViolation, | ||
) | ||
from wemake_python_styleguide.visitors.ast.conditions import IfStatementVisitor | ||
|
||
incorrect_conditions1 = """if some and ( | ||
other == 1 | ||
): | ||
... | ||
""" | ||
|
||
incorrect_conditions2 = """ | ||
if some or ( | ||
other == 1 | ||
): | ||
... | ||
""" | ||
|
||
incorrect_conditions3 = """if some and some_function( | ||
other, | ||
): | ||
... | ||
""" | ||
|
||
incorrect_conditions4 = """ | ||
if some or some_func( | ||
other, | ||
): | ||
... | ||
""" | ||
|
||
incorrect_conditions5 = """ | ||
if very_long_call_name( | ||
long_parameter_name=long_variable_name, | ||
): | ||
... | ||
""" | ||
|
||
correct_conditions1 = """ | ||
if some and other or something: | ||
... | ||
""" | ||
|
||
correct_conditions2 = """ | ||
if some_func(k) and (some or other): | ||
... | ||
""" | ||
|
||
correct_conditions3 = """ | ||
if (some_func(k) and some) or other in (1,2,3): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, add: correct_conditions4 = """
if one:
if two:
...
""" |
||
... | ||
""" | ||
|
||
correct_conditions4 = """ | ||
if one: | ||
if two: | ||
... | ||
""" | ||
|
||
@pytest.mark.parametrize('code', [ | ||
incorrect_conditions1, | ||
incorrect_conditions2, | ||
incorrect_conditions3, | ||
incorrect_conditions4, | ||
incorrect_conditions5, | ||
]) | ||
def test_incorrect_multiline_conditions( | ||
assert_errors, | ||
parse_ast_tree, | ||
code, | ||
default_options, | ||
mode, | ||
): | ||
"""Testing multiline conditions.""" | ||
tree = parse_ast_tree(mode(code)) | ||
visitor = IfStatementVisitor(default_options, tree=tree) | ||
visitor.run() | ||
assert_errors(visitor, [MultilineConditionsViolation]) | ||
|
||
|
||
@pytest.mark.parametrize('code', [ | ||
correct_conditions1, | ||
correct_conditions2, | ||
correct_conditions3, | ||
correct_conditions4, | ||
]) | ||
def test_correct_multiline_conditions( | ||
assert_errors, | ||
parse_ast_tree, | ||
code, | ||
default_options, | ||
mode, | ||
): | ||
"""Testing multiline conditions.""" | ||
tree = parse_ast_tree(mode(code)) | ||
visitor = IfStatementVisitor(default_options, tree=tree) | ||
visitor.run() | ||
assert_errors(visitor, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need in putting all of these cases inside
noqa.py
.It only contains integration tests. One is enough.
Move other cases into unit tests.