diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-11-28 15:02:59 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-12-03 18:38:20 +0100 |
commit | 6c7fbc230bf77429423bbded6f7cb56ea7ef6a40 (patch) | |
tree | 9b84da6c9c267cd0220b340d774ef9daa3951dda | |
parent | 833ed555101abc1e85386dabc378586700ac8a96 (diff) | |
download | pylint-git-6c7fbc230bf77429423bbded6f7cb56ea7ef6a40.tar.gz |
Move the function go retrieve test file to pylint.testutil.functional
-rw-r--r-- | pylint/testutils/functional/__init__.py | 6 | ||||
-rw-r--r-- | pylint/testutils/functional/find_functional_tests.py | 30 | ||||
-rw-r--r-- | tests/test_functional.py | 29 |
3 files changed, 42 insertions, 23 deletions
diff --git a/pylint/testutils/functional/__init__.py b/pylint/testutils/functional/__init__.py index 64c150d7e..a97eea0bb 100644 --- a/pylint/testutils/functional/__init__.py +++ b/pylint/testutils/functional/__init__.py @@ -3,10 +3,16 @@ __all__ = [ "FunctionalTestFile", + "REASONABLY_DISPLAYABLE_VERTICALLY", + "get_functional_test_files_from_directory", "NoFileError", "parse_python_version", ] +from pylint.testutils.functional.find_functional_tests import ( + REASONABLY_DISPLAYABLE_VERTICALLY, + get_functional_test_files_from_directory, +) from pylint.testutils.functional.test_file import ( FunctionalTestFile, NoFileError, diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py new file mode 100644 index 000000000..6eab2e9e8 --- /dev/null +++ b/pylint/testutils/functional/find_functional_tests.py @@ -0,0 +1,30 @@ +# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE + +import os +from pathlib import Path +from typing import List, Union + +from pylint.testutils.functional.test_file import FunctionalTestFile + +# 'Wet finger' number of files that are reasonable to display by an IDE +# 'Wet finger' as in 'in my settings there are precisely this many'. +REASONABLY_DISPLAYABLE_VERTICALLY = 48 + + +def get_functional_test_files_from_directory( + input_dir: Union[Path, str] +) -> List[FunctionalTestFile]: + suite = [] + for dirpath, _, filenames in os.walk(input_dir): + if dirpath.endswith("__pycache__"): + continue + + assert ( + len(filenames) <= REASONABLY_DISPLAYABLE_VERTICALLY + ), f"{dirpath} contain too much functional tests files." + + for filename in filenames: + if filename != "__init__.py" and filename.endswith(".py"): + suite.append(FunctionalTestFile(dirpath, filename)) + return suite diff --git a/tests/test_functional.py b/tests/test_functional.py index 45edb49fb..d39d20583 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -26,7 +26,7 @@ import csv import os import sys from pathlib import Path -from typing import List, Union +from typing import Union import pytest from _pytest.config import Config @@ -34,15 +34,16 @@ from _pytest.recwarn import WarningsRecorder from pylint import testutils from pylint.testutils import UPDATE_FILE, UPDATE_OPTION -from pylint.testutils.functional.test_file import FunctionalTestFile +from pylint.testutils.functional import ( + FunctionalTestFile, + get_functional_test_files_from_directory, +) from pylint.utils import HAS_ISORT_5 # TODOs # - implement exhaustivity tests -# 'Wet finger' number of files that are reasonable to display by an IDE -# 'Wet finger' as in 'in my settings there are precisely this many'. -REASONABLY_DISPLAYABLE_VERTICALLY = 48 + FUNCTIONAL_DIR = Path(__file__).parent.resolve() / "functional" @@ -66,24 +67,6 @@ class LintModuleOutputUpdate(testutils.LintModuleTest): writer.writerow(line.to_csv()) -def get_functional_test_files_from_directory( - input_dir: Union[Path, str] -) -> List[FunctionalTestFile]: - suite = [] - for dirpath, _, filenames in os.walk(input_dir): - if dirpath.endswith("__pycache__"): - continue - - assert ( - len(filenames) <= REASONABLY_DISPLAYABLE_VERTICALLY - ), f"{dirpath} contain too much functional tests files." - - for filename in filenames: - if filename != "__init__.py" and filename.endswith(".py"): - suite.append(testutils.FunctionalTestFile(dirpath, filename)) - return suite - - # isort 5 has slightly different rules as isort 4. Testing both would be hard: test with isort 5 only. TESTS = [ t |