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