From 2bb4ca63a94ac1ef537c27b3fa2fba14d819a49e Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk <21087696+oleksandr-pavlyk@users.noreply.github.com> Date: Mon, 29 Jun 2026 12:25:45 -0500 Subject: [PATCH] Test packaged import path. test_nvbench_tooling_deps.py now has a smoke test that builds a temporary package layout matching the wheel mapping: cuda/bench/scripts/nvbench_tooling_deps.py and imports: cuda.bench.scripts.nvbench_tooling_deps That covers the cuda.bench.scripts.* path without requiring a wheel build/install inside this unit test. --- python/test/test_nvbench_tooling_deps.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/python/test/test_nvbench_tooling_deps.py b/python/test/test_nvbench_tooling_deps.py index 27c2801..ff91325 100644 --- a/python/test/test_nvbench_tooling_deps.py +++ b/python/test/test_nvbench_tooling_deps.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception import importlib +import shutil import sys from pathlib import Path @@ -16,6 +17,25 @@ def tooling_deps(monkeypatch): return importlib.import_module("nvbench_tooling_deps") +def test_tooling_deps_imports_from_packaged_script_path(tmp_path, monkeypatch): + scripts_dir = Path(__file__).resolve().parents[1] / "scripts" + package_dir = tmp_path / "cuda" / "bench" / "scripts" + package_dir.mkdir(parents=True) + for package in [tmp_path / "cuda", tmp_path / "cuda" / "bench", package_dir]: + (package / "__init__.py").write_text("", encoding="utf-8") + shutil.copy( + scripts_dir / "nvbench_tooling_deps.py", + package_dir / "nvbench_tooling_deps.py", + ) + + monkeypatch.syspath_prepend(str(tmp_path)) + sys.modules.pop("cuda.bench.scripts.nvbench_tooling_deps", None) + + module = importlib.import_module("cuda.bench.scripts.nvbench_tooling_deps") + + assert module.ToolingDependency("math", "math", "testing").extra == "tools" + + def test_require_tooling_dependency_returns_loaded_module(tooling_deps): module = tooling_deps.require_tooling_dependency( tooling_deps.ToolingDependency("math", "math", "testing"),