diff --git a/pylint/testutils/configuration_test.py b/pylint/testutils/configuration_test.py index 14944471a73..12f4a32635d 100644 --- a/pylint/testutils/configuration_test.py +++ b/pylint/testutils/configuration_test.py @@ -12,7 +12,7 @@ from pylint.lint import Run -USER_SPECIFIC_PATH = str(Path(__file__).parent.parent.parent) +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,10 +71,10 @@ def get_expected_configuration( return result -def get_relative_path(path: str, user_specific_path: str = USER_SPECIFIC_PATH) -> str: +def get_relative_path(path: str, user_specific_path: Path = USER_SPECIFIC_PATH) -> str: """Get the relative path we want without the user specific path""" # [1:] is to remove the opening '/' - return path.split(user_specific_path)[1][1:] + return str(Path(path).relative_to(user_specific_path)) def get_expected_output(configuration_path: str) -> Tuple[int, str]: @@ -91,7 +91,7 @@ def get_expected_output(configuration_path: str) -> Tuple[int, str]: else: logging.info(".out file does not exists, so the expected exit code is 0") exit_code = 0 - relpath = get_relative_path(configuration_path, USER_SPECIFIC_PATH) + relpath = get_relative_path(configuration_path) return exit_code, output.format(abspath=configuration_path, relpath=relpath)