diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-12-13 14:14:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 14:14:54 +0100 |
commit | 736c0be70590dfafaf0905a670505e4ff380d5a4 (patch) | |
tree | 6ea5c0f372946fd31622a56c990f9e41ec2d1295 | |
parent | 2920947fbd730c39282e2070f073e103f52ae580 (diff) | |
download | pylint-git-736c0be70590dfafaf0905a670505e4ff380d5a4.tar.gz |
Unify validation of functional test option files (#5510)
-rw-r--r-- | pylint/testutils/functional/test_file.py | 13 | ||||
-rw-r--r-- | pylint/testutils/lint_module_test.py | 6 |
2 files changed, 9 insertions, 10 deletions
diff --git a/pylint/testutils/functional/test_file.py b/pylint/testutils/functional/test_file.py index 8aa0361d4..b25fe509b 100644 --- a/pylint/testutils/functional/test_file.py +++ b/pylint/testutils/functional/test_file.py @@ -27,8 +27,8 @@ class TestFileOptions(TypedDict): max_pyver: Tuple[int, ...] min_pyver_end_position: Tuple[int, ...] requires: List[str] - except_implementations: str # Type is actually comma separated list of string - exclude_platforms: str # Type is actually comma separated list of string + except_implementations: List[str] + exclude_platforms: List[str] # mypy need something literal, we can't create this dynamically from TestFileOptions @@ -39,7 +39,6 @@ POSSIBLE_TEST_OPTIONS = { "requires", "except_implementations", "exclude_platforms", - "exclude_platforms", } @@ -50,7 +49,9 @@ class FunctionalTestFile: "min_pyver": parse_python_version, "max_pyver": parse_python_version, "min_pyver_end_position": parse_python_version, - "requires": lambda s: s.split(","), + "requires": lambda s: [i.strip() for i in s.split(",")], + "except_implementations": lambda s: [i.strip() for i in s.split(",")], + "exclude_platforms": lambda s: [i.strip() for i in s.split(",")], } def __init__(self, directory: str, filename: str) -> None: @@ -61,8 +62,8 @@ class FunctionalTestFile: "max_pyver": (4, 0), "min_pyver_end_position": (3, 8), "requires": [], - "except_implementations": "", - "exclude_platforms": "", + "except_implementations": [], + "exclude_platforms": [], } self._parse_options() diff --git a/pylint/testutils/lint_module_test.py b/pylint/testutils/lint_module_test.py index cbdedeecc..b7e1ffc67 100644 --- a/pylint/testutils/lint_module_test.py +++ b/pylint/testutils/lint_module_test.py @@ -74,14 +74,12 @@ class LintModuleTest: pytest.skip(f"Requires {','.join(missing)} to be present.") except_implementations = self._test_file.options["except_implementations"] if except_implementations: - implementations = [i.strip() for i in except_implementations.split(",")] - if platform.python_implementation() in implementations: + if platform.python_implementation() in except_implementations: msg = "Test cannot run with Python implementation %r" pytest.skip(msg % platform.python_implementation()) excluded_platforms = self._test_file.options["exclude_platforms"] if excluded_platforms: - platforms = [p.strip() for p in excluded_platforms.split(",")] - if sys.platform.lower() in platforms: + if sys.platform.lower() in excluded_platforms: pytest.skip(f"Test cannot run on platform {sys.platform!r}") def runTest(self) -> None: |