Skip to content

Commit 5ba032c

Browse files
committed
Show abs_path suitable for copy-pasting in shell
1 parent edff6ec commit 5ba032c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cuda_pathfinder/tests/test_load_nvidia_dynamic_lib.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import functools
55
import json
66
import os
7+
import shlex
8+
from subprocess import list2cmdline # nosec B404
79
from unittest.mock import patch
810

911
import pytest
@@ -91,6 +93,12 @@ def _get_libnames_for_test_load_nvidia_dynamic_lib():
9193
return tuple(result)
9294

9395

96+
def _quote_for_shell_copypaste(s):
97+
if os.name == "nt":
98+
return list2cmdline([s])
99+
return shlex.quote(s)
100+
101+
94102
@pytest.mark.parametrize("libname", _get_libnames_for_test_load_nvidia_dynamic_lib())
95103
def test_load_nvidia_dynamic_lib(info_summary_append, libname):
96104
# We intentionally run each dynamic library operation in a child process
@@ -112,5 +120,5 @@ def raise_child_process_failed():
112120
info_summary_append(f"Not found: {libname=!r}")
113121
else:
114122
abs_path = json.loads(result.stdout.rstrip())
115-
info_summary_append(f"{abs_path=}")
123+
info_summary_append(f"abs_path={_quote_for_shell_copypaste(abs_path)}")
116124
assert os.path.isfile(abs_path) # double-check the abs_path

0 commit comments

Comments
 (0)