Normalize the source open mock through os_long_path before comparing
The hashing code opens the source file through paths.os_long_path,
which on win32 prepends the extended length backslash backslash
question mark backslash marker so a long path survives open. The
denied source mock compared that prefixed string against the plain
fixture path as ordinary Path objects, which never match on Windows
since neither Path equality nor resolve strips that marker. The mock
never raised, so the source failure branch silently exercised the
readable file case instead of the intended permission error, while
the sibling manifest branch already compared through resolve and
passed.
Normalize both sides through the same os_long_path helper the
source itself uses before comparing, so the two forms agree on every
platform.
(cherry picked from commit ff45f7049c)
This commit is contained in:
1 parent
499137470d
commit
83ca144577
1 file changed
+8
-1
@@ -152,7 +152,14 @@ def test_read_errors_stay_stale(tmp_path, monkeypatch, failure):
|
||||
original_open = builtins.open
|
||||
|
||||
def denied_source(file, *args, **kwargs):
|
||||
if Path(file) == f:
|
||||
# The hashing code opens the source through paths.os_long_path,
|
||||
# which on win32 prepends the extended-length \\?\ marker so long
|
||||
# paths survive open(). Comparing that prefixed string straight
|
||||
# against f as plain Path objects never matches on Windows, so
|
||||
# the mock never raised and this branch silently tested the
|
||||
# readable-file case instead. Normalize both sides the same way
|
||||
# the source itself does before comparing.
|
||||
if paths.os_long_path(file) == paths.os_long_path(f):
|
||||
raise PermissionError("unreadable fixture")
|
||||
return original_open(file, *args, **kwargs)
|
||||
|
||||
|
||||
Reference in new issue
Block a user