-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Илья Лебедев
committed
Feb 15, 2019
1 parent
6c1624b
commit dac5a8a
Showing
7 changed files
with
107 additions
and
58 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
check: | ||
flake8 . | ||
mypy . | ||
python -m pytest --cov=flake8_class_attributes_order --cov-report=xml |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ast | ||
import os | ||
|
||
from flake8_class_attributes_order.checker import ClassAttributesOrderChecker | ||
|
||
|
||
def run_validator_for_test_file(filename, max_annotations_complexity=None): | ||
test_file_path = os.path.join( | ||
os.path.dirname(os.path.abspath(__file__)), | ||
'test_files', | ||
filename, | ||
) | ||
with open(test_file_path, 'r') as file_handler: | ||
raw_content = file_handler.read() | ||
tree = ast.parse(raw_content) | ||
checker = ClassAttributesOrderChecker(tree=tree, filename=filename) | ||
if max_annotations_complexity: | ||
checker.max_annotations_complexity = max_annotations_complexity | ||
|
||
return list(checker.run()) |
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,6 @@ | ||
from conftest import run_validator_for_test_file | ||
|
||
|
||
def test_always_ok_for_empty_file(): | ||
errors = run_validator_for_test_file('errored.py') | ||
assert len(errors) == 2 |
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,17 @@ | ||
DEBUG = True | ||
|
||
|
||
class User: | ||
def fetch_info_from_crm(self): | ||
pass | ||
|
||
LOGIN_FIELD = 'email' # wtf? this should on top of class definition! | ||
|
||
|
||
class UserNode: | ||
class Meta: | ||
model = User | ||
|
||
if DEBUG: # not great idea at all | ||
def is_synced_with_crm(self): | ||
pass |