From: Zack Cerza Date: Thu, 25 Jul 2024 20:29:15 +0000 (-0600) Subject: Rewrite module import tests X-Git-Tag: 1.2.0~9^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0d1fc3bda45b497ca68427a20a0bf859b02efb91;p=teuthology.git Rewrite module import tests These are 38x faster. They also helped me find and fix a bug in the exporter Signed-off-by: Zack Cerza --- diff --git a/teuthology/test/test_imports.py b/teuthology/test/test_imports.py index b73ade15e..cb25c8d0a 100644 --- a/teuthology/test/test_imports.py +++ b/teuthology/test/test_imports.py @@ -1,7 +1,8 @@ +import importlib import pytest +import sys from pathlib import Path -from subprocess import check_call from typing import List root = Path("./teuthology") @@ -26,4 +27,5 @@ def find_modules() -> List[str]: @pytest.mark.parametrize("module", find_modules()) def test_import_modules(module): - check_call(["python3", "-c", f"import {module}"]) + importlib.import_module(module) + assert module in sys.modules