Skip to content

Commit

Permalink
Trying to use pathlib.Path to fix issue with relative path on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Nov 12, 2021
1 parent 93dc0bc commit 3895bd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pylint/testutils/configuration_test.py
Expand Up @@ -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
Expand Down Expand Up @@ -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]:
Expand All @@ -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)


Expand Down

0 comments on commit 3895bd8

Please sign in to comment.