forked from PyCQA/pydocstyle
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_definitions.py
44 lines (41 loc) · 1.42 KB
/
test_definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Old parser tests."""
import os
import re
import pytest
from pydocstyle.violations import Error, ErrorRegistry
from pydocstyle.checker import check
@pytest.mark.parametrize('test_case', [
'test',
'unicode_literals',
'nested_class',
'capitalization',
'comment_after_def_bug',
'multi_line_summary_start',
'all_import',
'all_import_as',
'superfluous_quotes',
'noqa',
'sections',
'functions',
'canonical_google_examples',
'canonical_numpy_examples',
'canonical_pep257_examples',
])
def test_complex_file(test_case):
"""Run domain-specific tests from test.py file."""
case_module = __import__(f'test_cases.{test_case}',
globals=globals(),
locals=locals(),
fromlist=['expectation'],
level=1)
test_case_dir = os.path.normcase(os.path.dirname(__file__))
test_case_file = os.path.join(test_case_dir,
'test_cases',
test_case + '.py')
results = list(check([test_case_file],
select=set(ErrorRegistry.get_error_codes()),
ignore_decorators=re.compile('wraps')))
for error in results:
assert isinstance(error, Error)
results = {(e.definition.name, e.message) for e in results}
assert case_module.expectation.expected == results