add tests for the django test suite

This commit is contained in:
Maxim Kurnikov
2019-01-26 17:17:35 +03:00
parent 38e841c4c7
commit 1afa079b0b
18 changed files with 232 additions and 57 deletions

View File

@@ -2,10 +2,55 @@ import os
if not os.path.exists('./django-sources'):
git clone -b stable/2.1.x https://github.com/django/django.git django-sources
ignored_error_patterns = ["Need type annotation for", "already defined on", "Cannot assign to a"]
for line in $(mypy --config-file ./scripts/mypy.ini ./django-sources/tests).split('\n'):
for pattern in ignored_error_patterns:
if pattern in line:
break
else:
print(line)
IGNORED_ERROR_PATTERNS = [
'Need type annotation for',
'already defined on',
'Cannot assign to a',
'cannot perform relative import',
'broken_app',
'LazySettings',
'Cannot infer type of lambda',
'Incompatible types in assignment (expression has type "Callable[',
'"Callable[[Any], Any]" has no attribute',
'Invalid value for a to= parameter'
]
TESTS_DIRS = [
'absolute_url_overrides',
'admin_*',
'aggregation*',
'annotations'
]
def check_file_in_the_current_directory(directory, fname):
cd @(directory)
with ${...}.swap(FNAME=fname):
for line in $(mypy --config-file ../../../scripts/mypy.ini $FNAME).split('\n'):
for pattern in IGNORED_ERROR_PATTERNS:
if pattern in line:
break
else:
if line:
print(line)
cd -
def parse_ls_output_into_fnames(output):
fnames = []
for line in output.splitlines()[1:]:
fnames.append(line.split()[-1])
return fnames
all_tests_dirs = []
for test_dir in TESTS_DIRS:
with ${...}.swap(TEST_DIR=test_dir):
dirs = g`django-sources/tests/$TEST_DIR`
all_tests_dirs.extend(dirs)
for tests_dir in all_tests_dirs:
print('Checking ' + tests_dir)
abs_dir = os.path.join(os.getcwd(), tests_dir)
with ${...}.swap(ABS_DIR=abs_dir):
ls_output = $(ls $ABS_DIR)
for fname in parse_ls_output_into_fnames(ls_output):
path_to_check = os.path.join(abs_dir, fname)
check_file_in_the_current_directory(abs_dir, fname)