|
5 | 5 | # Pytest fixtures work like this by design |
6 | 6 | # pylint: disable=redefined-outer-name |
7 | 7 |
|
| 8 | +import sys |
8 | 9 | from pathlib import Path |
9 | 10 |
|
10 | 11 | import pytest |
|
18 | 19 |
|
19 | 20 |
|
20 | 21 | @pytest.mark.parametrize( |
21 | | - "path,recur,expected", |
| 22 | + "path,recur,pylint_home,expected", |
22 | 23 | [ |
23 | | - ["", 1, PYLINT_HOME_PATH / "_1.stats"], |
24 | | - ["", 2, PYLINT_HOME_PATH / "_2.stats"], |
25 | | - ["a/path", 42, PYLINT_HOME_PATH / "a_path_42.stats"], |
| 24 | + ["", 1, PYLINT_HOME_PATH, PYLINT_HOME_PATH / "_1.stats"], |
| 25 | + ["", 2, PYLINT_HOME_PATH, PYLINT_HOME_PATH / "_2.stats"], |
| 26 | + ["a/path", 42, PYLINT_HOME_PATH, PYLINT_HOME_PATH / "a_path_42.stats"], |
26 | 27 | ], |
27 | 28 | ) |
28 | | -def test__get_pdata_path(path: str, recur: int, expected: Path) -> None: |
29 | | - assert _get_pdata_path(Path(path), recur) == expected |
| 29 | +def test__get_pdata_path( |
| 30 | + path: str, recur: int, pylint_home: Path, expected: Path |
| 31 | +) -> None: |
| 32 | + assert _get_pdata_path(Path(path), recur, pylint_home) == expected |
| 33 | + |
| 34 | + |
| 35 | +@pytest.mark.skipif(sys.platform == "win32", reason="Path type of *nix") |
| 36 | +@pytest.mark.parametrize( |
| 37 | + "path,recur,pylint_home,expected", |
| 38 | + [ |
| 39 | + [ |
| 40 | + "/workspace/MyDir/test.py", |
| 41 | + 1, |
| 42 | + Path("/root/.cache/pylint"), |
| 43 | + Path("/root/.cache/pylint") / "__workspace_MyDir_test.py_1.stats", |
| 44 | + ], |
| 45 | + [ |
| 46 | + "/workspace/MyDir/test.py", |
| 47 | + 1, |
| 48 | + Path("//host/computer/.cache"), |
| 49 | + Path("//host/computer/.cache") / "__workspace_MyDir_test.py_1.stats", |
| 50 | + ], |
| 51 | + ], |
| 52 | +) |
| 53 | +def test__get_pdata_path_nix( |
| 54 | + path: str, recur: int, pylint_home: Path, expected: Path |
| 55 | +) -> None: |
| 56 | + """test__get_pdata_path but specifically for *nix system paths.""" |
| 57 | + assert _get_pdata_path(Path(path), recur, pylint_home) == expected |
| 58 | + |
| 59 | + |
| 60 | +@pytest.mark.skipif(sys.platform != "win32", reason="Path type of windows") |
| 61 | +@pytest.mark.parametrize( |
| 62 | + "path,recur,pylint_home,expected", |
| 63 | + [ |
| 64 | + [ |
| 65 | + "D:\\MyDir\\test.py", |
| 66 | + 1, |
| 67 | + Path("C:\\Users\\MyPylintHome"), |
| 68 | + Path("C:\\Users\\MyPylintHome") / "D___MyDir_test.py_1.stats", |
| 69 | + ], |
| 70 | + [ |
| 71 | + "C:\\MyDir\\test.py", |
| 72 | + 1, |
| 73 | + Path("C:\\Users\\MyPylintHome"), |
| 74 | + Path("C:\\Users\\MyPylintHome") / "C___MyDir_test.py_1.stats", |
| 75 | + ], |
| 76 | + ], |
| 77 | +) |
| 78 | +def test__get_pdata_path_windows( |
| 79 | + path: str, recur: int, pylint_home: Path, expected: Path |
| 80 | +) -> None: |
| 81 | + """test__get_pdata_path but specifically for windows.""" |
| 82 | + assert _get_pdata_path(Path(path), recur, pylint_home) == expected |
30 | 83 |
|
31 | 84 |
|
32 | 85 | @pytest.fixture |
|
0 commit comments