From cdde569e4384e9144a5f6eb9754afd3efec06089 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 20 Mar 2023 13:28:48 -0600 Subject: [PATCH] Test all module imports Signed-off-by: Zack Cerza --- teuthology/test/test_imports.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 teuthology/test/test_imports.py diff --git a/teuthology/test/test_imports.py b/teuthology/test/test_imports.py new file mode 100644 index 0000000000..b73ade15ec --- /dev/null +++ b/teuthology/test/test_imports.py @@ -0,0 +1,29 @@ +import pytest + +from pathlib import Path +from subprocess import check_call +from typing import List + +root = Path("./teuthology") + + +def find_modules() -> List[str]: + modules = [] + for path in root.rglob("*.py"): + if path.name.startswith("test_"): + continue + if "-" in path.name: + continue + if path.name == "__init__.py": + path = path.parent + + path_name = str(path).replace("/", ".") + if path_name.endswith(".py"): + path_name = path_name[:-3] + modules.append(path_name) + return sorted(modules) + + +@pytest.mark.parametrize("module", find_modules()) +def test_import_modules(module): + check_call(["python3", "-c", f"import {module}"]) -- 2.39.5