From 177503df25daea032a97036ce6fd261ddde6d251 Mon Sep 17 00:00:00 2001 From: Mike Hendricks Date: Wed, 4 Dec 2024 12:01:23 -0800 Subject: [PATCH] `WinPlatform.normalize_path` no longer changes the UNC drive case --- hab/utils.py | 3 ++- tests/test_resolver.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hab/utils.py b/hab/utils.py index c0e00bc..d524350 100644 --- a/hab/utils.py +++ b/hab/utils.py @@ -581,7 +581,8 @@ def normalize_path(cls, path): This ensures that the drive letter is resolved consistently to uppercase. """ - if not path.is_absolute(): + # Don't change the case of relative or UNC paths + if not path.is_absolute() or ":" not in path.drive: return path parts = path.parts cls = type(path) diff --git a/tests/test_resolver.py b/tests/test_resolver.py index dc5107d..4a073b4 100644 --- a/tests/test_resolver.py +++ b/tests/test_resolver.py @@ -851,8 +851,12 @@ def test_normalize_path_preserves_cls(self, cls, platform): # the drive letter is always upper-cased if specified (r"c:\temp", "C:/temp"), (r"C:\temp", "C:/temp"), + (r"C:\teMP", "C:/teMP"), (r"z:\subfolder", "Z:/subfolder"), (r"relative\path", "relative/path"), + # UNC file paths do not have case changed + (r"\\unc\share\folder", "//unc/share/folder"), + (r"\\UnC\shaRe\folDer", "//UnC/shaRe/folDer"), ), ) def test_normalize_path_windows(self, path, check):