|
1 | 1 | """Old parser tests."""
|
2 | 2 |
|
3 |
| -import sys |
4 | 3 | import os
|
5 |
| -import os.path |
6 | 4 | import re
|
7 | 5 | import pytest
|
8 | 6 | from pydocstyle.violations import Error, ErrorRegistry
|
|
26 | 24 | 'canonical_numpy_examples',
|
27 | 25 | 'canonical_pep257_examples',
|
28 | 26 | ])
|
29 |
| -def test_all_interpreters(test_case): |
30 |
| - """Complex test cases that run under all interpreters.""" |
31 |
| - run_case(test_case) |
32 |
| - |
33 |
| - |
34 |
| -@pytest.mark.skipif( |
35 |
| - sys.version_info < (3, 6), |
36 |
| - reason="f-string support needed" |
37 |
| -) |
38 |
| -def test_fstrings(): |
39 |
| - """Run the f-string test case under Python 3.6+ only.""" |
40 |
| - # When run under Python 3.5, mypy reports a parse error for the test file, |
41 |
| - # because Python 3.5 doesn't support f-strings. It does not support |
42 |
| - # ignoring parse errors. |
43 |
| - # |
44 |
| - # To work around this, we put our code in a file that mypy cannot see. This |
45 |
| - # code reveals it to Python. |
46 |
| - from . import test_cases |
47 |
| - import importlib.machinery |
48 |
| - test_cases_dir = test_cases.__path__[0] |
49 |
| - loader = sys.path_importer_cache[test_cases_dir] |
50 |
| - loader._loaders.append(('.py36', importlib.machinery.SourceFileLoader)) |
51 |
| - |
52 |
| - run_case('fstrings') |
53 |
| - |
54 |
| - |
55 |
| -def run_case(test_case): |
| 27 | +def test_complex_file(test_case): |
56 | 28 | """Run domain-specific tests from test.py file."""
|
57 | 29 | case_module = __import__(f'test_cases.{test_case}',
|
58 | 30 | globals=globals(),
|
59 | 31 | locals=locals(),
|
60 | 32 | fromlist=['expectation'],
|
61 | 33 | level=1)
|
62 |
| - |
63 |
| - test_case_file = os.path.relpath(case_module.__file__) |
| 34 | + test_case_dir = os.path.normcase(os.path.dirname(__file__)) |
| 35 | + test_case_file = os.path.join(test_case_dir, |
| 36 | + 'test_cases', |
| 37 | + test_case + '.py') |
64 | 38 | results = list(check([test_case_file],
|
65 | 39 | select=set(ErrorRegistry.get_error_codes()),
|
66 | 40 | ignore_decorators=re.compile(
|
|
0 commit comments