jamescooke/flake8-aaa

Simple test files are not checked

jamescooke opened this issue · 0 comments

Django tutorial has:

Put the following in the tests.py file in the polls application

But Flake8-AAA does not check files tests.py or test.py 🤕 ... instead it only picks up test_ prefixed files. This can cause confusion.

Instead, add tests.py and test.py to the list of files checked by Flake8-AAA. Func that requires tweaking is here:

def is_test_file(filename: str) -> bool:
"""
Check that path to file being checked passed by flake8 looks like a pytest
test file.
Examples:
1. Non-test files give False.
>>> is_test_file('./test.py')
False
>>> is_test_file('./helper.py')
False
>>> is_test_file('tests/conftest.py')
False
2. Finds files that start with 'test_' to be test files.
>>> is_test_file('./test_helpers.py')
True
"""
return os.path.basename(filename).startswith('test_')