Skip to content

Commit 6c7fbc2

Browse files
Move the function go retrieve test file to pylint.testutil.functional
1 parent 833ed55 commit 6c7fbc2

File tree

3 files changed

+42
-23
lines changed

3 files changed

+42
-23
lines changed

pylint/testutils/functional/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33

44
__all__ = [
55
"FunctionalTestFile",
6+
"REASONABLY_DISPLAYABLE_VERTICALLY",
7+
"get_functional_test_files_from_directory",
68
"NoFileError",
79
"parse_python_version",
810
]
911

12+
from pylint.testutils.functional.find_functional_tests import (
13+
REASONABLY_DISPLAYABLE_VERTICALLY,
14+
get_functional_test_files_from_directory,
15+
)
1016
from pylint.testutils.functional.test_file import (
1117
FunctionalTestFile,
1218
NoFileError,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2+
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
3+
4+
import os
5+
from pathlib import Path
6+
from typing import List, Union
7+
8+
from pylint.testutils.functional.test_file import FunctionalTestFile
9+
10+
# 'Wet finger' number of files that are reasonable to display by an IDE
11+
# 'Wet finger' as in 'in my settings there are precisely this many'.
12+
REASONABLY_DISPLAYABLE_VERTICALLY = 48
13+
14+
15+
def get_functional_test_files_from_directory(
16+
input_dir: Union[Path, str]
17+
) -> List[FunctionalTestFile]:
18+
suite = []
19+
for dirpath, _, filenames in os.walk(input_dir):
20+
if dirpath.endswith("__pycache__"):
21+
continue
22+
23+
assert (
24+
len(filenames) <= REASONABLY_DISPLAYABLE_VERTICALLY
25+
), f"{dirpath} contain too much functional tests files."
26+
27+
for filename in filenames:
28+
if filename != "__init__.py" and filename.endswith(".py"):
29+
suite.append(FunctionalTestFile(dirpath, filename))
30+
return suite

tests/test_functional.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@
2626
import os
2727
import sys
2828
from pathlib import Path
29-
from typing import List, Union
29+
from typing import Union
3030

3131
import pytest
3232
from _pytest.config import Config
3333
from _pytest.recwarn import WarningsRecorder
3434

3535
from pylint import testutils
3636
from pylint.testutils import UPDATE_FILE, UPDATE_OPTION
37-
from pylint.testutils.functional.test_file import FunctionalTestFile
37+
from pylint.testutils.functional import (
38+
FunctionalTestFile,
39+
get_functional_test_files_from_directory,
40+
)
3841
from pylint.utils import HAS_ISORT_5
3942

4043
# TODOs
4144
# - implement exhaustivity tests
4245

43-
# 'Wet finger' number of files that are reasonable to display by an IDE
44-
# 'Wet finger' as in 'in my settings there are precisely this many'.
45-
REASONABLY_DISPLAYABLE_VERTICALLY = 48
46+
4647
FUNCTIONAL_DIR = Path(__file__).parent.resolve() / "functional"
4748

4849

@@ -66,24 +67,6 @@ def _check_output_text(self, _, expected_output, actual_output):
6667
writer.writerow(line.to_csv())
6768

6869

69-
def get_functional_test_files_from_directory(
70-
input_dir: Union[Path, str]
71-
) -> List[FunctionalTestFile]:
72-
suite = []
73-
for dirpath, _, filenames in os.walk(input_dir):
74-
if dirpath.endswith("__pycache__"):
75-
continue
76-
77-
assert (
78-
len(filenames) <= REASONABLY_DISPLAYABLE_VERTICALLY
79-
), f"{dirpath} contain too much functional tests files."
80-
81-
for filename in filenames:
82-
if filename != "__init__.py" and filename.endswith(".py"):
83-
suite.append(testutils.FunctionalTestFile(dirpath, filename))
84-
return suite
85-
86-
8770
# isort 5 has slightly different rules as isort 4. Testing both would be hard: test with isort 5 only.
8871
TESTS = [
8972
t

0 commit comments

Comments
 (0)