summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-14 09:16:56 +0100
committerGitHub <noreply@github.com>2021-11-14 09:16:56 +0100
commite5082d3f9401dbcf65b40ce6a819d2a09beccb5c (patch)
tree9c7288868a8cdf0b1f96d88aa26904bf7b55f2dd
parent18c1bd2c50e5b0454275750376ef6bf4da0f2360 (diff)
downloadpylint-git-e5082d3f9401dbcf65b40ce6a819d2a09beccb5c.tar.gz
Fix user specific path in functional conf tests for tox (#5301)
Detected in https://github.com/PyCQA/pylint/pull/5287#issuecomment-968093640
-rw-r--r--pylint/testutils/configuration_test.py7
-rw-r--r--tests/config/test_functional_config_loading.py5
2 files changed, 8 insertions, 4 deletions
diff --git a/pylint/testutils/configuration_test.py b/pylint/testutils/configuration_test.py
index 2fac8f1c1..2a33d9388 100644
--- a/pylint/testutils/configuration_test.py
+++ b/pylint/testutils/configuration_test.py
@@ -12,7 +12,6 @@ from unittest.mock import Mock
from pylint.lint import Run
-USER_SPECIFIC_PATH = Path(__file__).parent.parent.parent
# We use Any in this typing because the configuration contains real objects and constants
# that could be a lot of things.
ConfigurationValue = Any
@@ -71,7 +70,9 @@ def get_expected_configuration(
return result
-def get_expected_output(configuration_path: str) -> Tuple[int, str]:
+def get_expected_output(
+ configuration_path: str, user_specific_path: Path
+) -> Tuple[int, str]:
"""Get the expected output of a functional test."""
output = get_expected_or_default(configuration_path, suffix="out", default="")
if output:
@@ -87,7 +88,7 @@ def get_expected_output(configuration_path: str) -> Tuple[int, str]:
exit_code = 0
return exit_code, output.format(
abspath=configuration_path,
- relpath=Path(configuration_path).relative_to(USER_SPECIFIC_PATH),
+ relpath=Path(configuration_path).relative_to(user_specific_path),
)
diff --git a/tests/config/test_functional_config_loading.py b/tests/config/test_functional_config_loading.py
index 452d7cc90..6ee86d679 100644
--- a/tests/config/test_functional_config_loading.py
+++ b/tests/config/test_functional_config_loading.py
@@ -32,6 +32,7 @@ from pylint.testutils.configuration_test import (
)
HERE = Path(__file__).parent
+USER_SPECIFIC_PATH = HERE.parent.parent
FUNCTIONAL_DIR = HERE / "functional"
# We use string then recast to path so we can use -k in pytest.
# Otherwise we get 'configuration_path0' as a test name. The path is relative to the functional
@@ -71,7 +72,9 @@ def test_functional_config_loading(
caplog.set_level(logging.INFO)
configuration_path = str(FUNCTIONAL_DIR / configuration_path)
msg = f"Wrong result with configuration {configuration_path}"
- expected_code, expected_output = get_expected_output(configuration_path)
+ expected_code, expected_output = get_expected_output(
+ configuration_path, USER_SPECIFIC_PATH
+ )
expected_loaded_configuration = get_expected_configuration(
configuration_path, default_configuration
)