|
5 | 5 | import contextlib
|
6 | 6 | import functools
|
7 | 7 | import tokenize
|
8 |
| -from glob import glob |
9 | 8 | from io import StringIO
|
10 |
| -from os.path import basename, join, splitext |
11 | 9 |
|
12 |
| -from pylint.testutils.constants import SYS_VERS_STR |
13 | 10 | from pylint.testutils.global_test_linter import linter
|
14 | 11 | from pylint.testutils.output_line import Message
|
15 | 12 | from pylint.utils import ASTWalker
|
16 | 13 |
|
17 | 14 |
|
18 |
| -def _get_tests_info(input_dir, msg_dir, prefix, suffix): |
19 |
| - """get python input examples and output messages |
20 |
| -
|
21 |
| - We use following conventions for input files and messages: |
22 |
| - for different inputs: |
23 |
| - test for python >= x.y -> input = <name>_pyxy.py |
24 |
| - test for python < x.y -> input = <name>_py_xy.py |
25 |
| - for one input and different messages: |
26 |
| - message for python >= x.y -> message = <name>_pyxy.txt |
27 |
| - lower versions -> message with highest num |
28 |
| - """ |
29 |
| - result = [] |
30 |
| - for fname in glob(join(input_dir, prefix + "*" + suffix)): |
31 |
| - infile = basename(fname) |
32 |
| - fbase = splitext(infile)[0] |
33 |
| - # filter input files : |
34 |
| - pyrestr = fbase.rsplit("_py", 1)[-1] # like _26 or 26 |
35 |
| - if pyrestr.isdigit(): # '24', '25'... |
36 |
| - if SYS_VERS_STR < pyrestr: |
37 |
| - continue |
38 |
| - if pyrestr.startswith("_") and pyrestr[1:].isdigit(): |
39 |
| - # skip test for higher python versions |
40 |
| - if SYS_VERS_STR >= pyrestr[1:]: |
41 |
| - continue |
42 |
| - messages = glob(join(msg_dir, fbase + "*.txt")) |
43 |
| - # the last one will be without ext, i.e. for all or upper versions: |
44 |
| - if messages: |
45 |
| - for outfile in sorted(messages, reverse=True): |
46 |
| - py_rest = outfile.rsplit("_py", 1)[-1][:-4] |
47 |
| - if py_rest.isdigit() and SYS_VERS_STR >= py_rest: |
48 |
| - break |
49 |
| - else: |
50 |
| - # This will provide an error message indicating the missing filename. |
51 |
| - outfile = join(msg_dir, fbase + ".txt") |
52 |
| - result.append((infile, outfile)) |
53 |
| - return result |
54 |
| - |
55 |
| - |
56 | 15 | class UnittestLinter:
|
57 | 16 | """A fake linter class to capture checker messages."""
|
58 | 17 |
|
|
0 commit comments