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.
This commit is contained in:
Oleksandr Pavlyk
2026-06-29 12:25:45 -05:00
parent 68d638ca85
commit 2bb4ca63a9

View File

@@ -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"),