From 4f82c022925bb7c09af2a25460269afb60bbf4d3 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Jun 2022 14:46:43 -0400 Subject: [PATCH 1/5] force / in actual_path() on Windows --- coverage/files.py | 1 + 1 file changed, 1 insertion(+) diff --git a/coverage/files.py b/coverage/files.py index 09f09da79..5db0de5c3 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -133,6 +133,7 @@ def actual_path(path): tail = f break actpath = os.path.join(head, tail) + actpath.replace("\\", "/") _ACTUAL_PATH_CACHE[path] = actpath return actpath From 7aec18faa1fc8dfb33b1925ec22a8f3315764a1c Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Jun 2022 14:59:14 -0400 Subject: [PATCH 2/5] actually assign --- coverage/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage/files.py b/coverage/files.py index 5db0de5c3..54d9d180a 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -133,7 +133,7 @@ def actual_path(path): tail = f break actpath = os.path.join(head, tail) - actpath.replace("\\", "/") + actpath = actpath.replace("\\", "/") _ACTUAL_PATH_CACHE[path] = actpath return actpath From a21325b696bc555164e6f2c7a4d74820e777b3a2 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Jun 2022 15:47:38 -0400 Subject: [PATCH 3/5] cover / normalization in existing actual_path() test --- tests/test_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_files.py b/tests/test_files.py index 5588c373d..fa598896e 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -428,4 +428,4 @@ class WindowsFileTest(CoverageTest): run_in_temp_dir = False def test_actual_path(self): - assert actual_path(r'c:\Windows') == actual_path(r'C:\wINDOWS') + assert actual_path(r'c:/Windows') == actual_path(r'C:\wINDOWS') From 64db1b9608eeff89ea351f1678b5fa3679da910d Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Jun 2022 20:47:54 -0400 Subject: [PATCH 4/5] try intercepting in the db instead --- coverage/files.py | 1 - coverage/sqldata.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage/files.py b/coverage/files.py index 54d9d180a..09f09da79 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -133,7 +133,6 @@ def actual_path(path): tail = f break actpath = os.path.join(head, tail) - actpath = actpath.replace("\\", "/") _ACTUAL_PATH_CACHE[path] = actpath return actpath diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 8d2ed73a5..ab7c437bb 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -384,6 +384,7 @@ def _file_id(self, filename, add=False): If filename is not in the database yet, add it if `add` is True. If `add` is not True, return None. """ + filename = filename.replace("\\", "/") if filename not in self._file_map: if add: with self._connect() as con: From 6b7ccb4c0b5742634dacd7e34699495c084bc6b3 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 20 Jun 2022 21:58:22 -0400 Subject: [PATCH 5/5] catch the aliases too --- coverage/files.py | 1 + 1 file changed, 1 insertion(+) diff --git a/coverage/files.py b/coverage/files.py index 09f09da79..80cb3a047 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -343,6 +343,7 @@ def add(self, pattern, result): match an entire tree, and not just its root. """ + pattern = pattern.replace("\\", "/") pattern_sep = sep(pattern) if len(pattern) > 1: