Skip to content

Commit d0af2c3

Browse files
committed
test: Use posixpath.isabs for the POSIX trusted-directory entries
test_all_entries_are_absolute failed the windows-latest 3.13 leg on '/run/wrappers/bin is not absolute'. From Python 3.13, ntpath.isabs() treats a single-slash path as drive-relative rather than absolute, so os.path.isabs made this assertion a statement about the host running the tests instead of about the constant. Every entry in TRUSTED_SYSTEM_DIRECTORIES is a POSIX path, and the module is POSIX-oriented, so posixpath.isabs is the right question to ask. Verified the mechanism locally rather than inferring it: ntpath.isabs ('/run/wrappers/bin') is False while posixpath.isabs is True. Same fix as the sibling job-attachments change; I applied it there and missed the twin here, which is why it only surfaced on the Windows leg after the other failure stopped masking it via fail-fast. 975 passed, 40 skipped, 16 xfailed. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
1 parent 110018a commit d0af2c3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎test/openjd/sessions_v0/test_system_commands.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import os
16+
import posixpath
1617
import stat
1718
from pathlib import Path
1819
from unittest.mock import patch
@@ -221,9 +222,16 @@ def test_is_still_distinguishable_from_a_plain_exec_failure(self) -> None:
221222
class TestTrustedDirectories:
222223
def test_all_entries_are_absolute(self) -> None:
223224
"""A relative entry would resolve against the process working directory,
224-
which a session changes."""
225+
which a session changes.
226+
227+
posixpath rather than os.path: these entries are POSIX paths, and from Python
228+
3.13 ntpath.isabs() treats a single-slash path as drive-relative rather than
229+
absolute. Using os.path made this a statement about the host running the
230+
tests rather than about the constant, and it failed the windows-latest 3.13
231+
leg on "/run/wrappers/bin is not absolute".
232+
"""
225233
for directory in TRUSTED_SYSTEM_DIRECTORIES:
226-
assert os.path.isabs(directory), f"{directory} is not absolute"
234+
assert posixpath.isabs(directory), f"{directory} is not absolute"
227235

228236
def test_searches_the_setuid_wrapper_directory_before_usr_bin(self) -> None:
229237
assert TRUSTED_SYSTEM_DIRECTORIES.index(

0 commit comments

Comments
 (0)