summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-01-22 18:27:21 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-01-22 18:27:21 +0100
commit201011fb56b07eafb7763bcc6c5e26abb30ffd88 (patch)
tree58af268299dda501d05ee81eafbe8cd113ff1d28
parente81141b9f8f9c10f136012e08eafda12249043cb (diff)
downloadnumpy-201011fb56b07eafb7763bcc6c5e26abb30ffd88.tar.gz
MAINT: Do not split at the first `:` character if the path contains a windows drive
-rw-r--r--numpy/typing/tests/test_typing.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index f41aa2b6b..324312a92 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -30,6 +30,15 @@ CACHE_DIR = os.path.join(DATA_DIR, ".mypy_cache")
OUTPUT_MYPY: Dict[str, List[str]] = {}
+def _key_func(key: str) -> str:
+ """Split at the first occurance of the ``:`` character.
+
+ Windows drive-letters (*e.g.* ``C:``) are ignored herein.
+ """
+ drive, tail = os.path.splitdrive(key)
+ return os.path.join(drive, tail.split(":", 1)[0])
+
+
@pytest.mark.slow
@pytest.mark.skipif(NO_MYPY, reason="Mypy is not installed")
@pytest.fixture(scope="module", autouse=True)
@@ -55,8 +64,7 @@ def run_mypy() -> None:
stdout = stdout.replace('*', '')
# Parse the output
- key = lambda n: n.split(':', 1)[0]
- iterator = itertools.groupby(stdout.split("\n"), key=key)
+ iterator = itertools.groupby(stdout.split("\n"), key=_key_func)
OUTPUT_MYPY.update((k, list(v)) for k, v in iterator if k)