Skip to content

Commit 1a5f518

Browse files
committed
Move the remaining test os.path calls to pathlib
The three os.path.abspath assertions in test_find_nvidia_binaries.py become str(...absolute()), and the os.path.isdir in test_utils_find_sub_dirs.py becomes Path.is_dir(). import os stays in the binaries test for os.sep.
1 parent 82f7dd3 commit 1a5f518

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

cuda_pathfinder/tests/test_find_nvidia_binaries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_find_binary_first_matching_dir_wins(monkeypatch, mocker):
153153
result = find_nvidia_binary_utility("nvcc")
154154

155155
# Conda comes before CUDA_HOME, so the Conda hit wins and CUDA_HOME is never probed.
156-
assert result == os.path.abspath(conda_nvcc)
156+
assert result == str(conda_nvcc.absolute())
157157
assert checked == [site_dir / "nvcc", conda_nvcc]
158158

159159

@@ -174,7 +174,7 @@ def test_find_binary_ctk_root_canary_fallback(monkeypatch, mocker):
174174

175175
result = find_nvidia_binary_utility("nvcc")
176176

177-
assert result == os.path.abspath(ctk_nvcc)
177+
assert result == str(ctk_nvcc.absolute())
178178
canary_mock.assert_called_once_with()
179179
# No earlier trusted dirs existed, so the only probe is the canary bin dir.
180180
assert checked == [ctk_nvcc]
@@ -219,7 +219,7 @@ def test_find_binary_canary_not_consulted_when_found_earlier(monkeypatch, mocker
219219

220220
result = find_nvidia_binary_utility("nvcc")
221221

222-
assert result == os.path.abspath(conda_nvcc)
222+
assert result == str(conda_nvcc.absolute())
223223
canary_mock.assert_not_called()
224224

225225

cuda_pathfinder/tests/test_utils_find_sub_dirs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import os
4+
from pathlib import Path
55

66
import pytest
77

@@ -77,7 +77,7 @@ def test_empty_parent_paths():
7777
def test_empty_sub_dirs(test_tree):
7878
parent_paths = test_tree["parent_paths"]
7979
result = find_sub_dirs(parent_paths, ())
80-
expected = [p for p in parent_paths if os.path.isdir(p)]
80+
expected = [p for p in parent_paths if Path(p).is_dir()]
8181
assert sorted(result) == sorted(expected)
8282

8383

0 commit comments

Comments
 (0)