diff --git a/src/gt4py/next/program_processors/runners/dace_iterator/__init__.py b/src/gt4py/next/program_processors/runners/dace_iterator/__init__.py index 47d8185e44..a124f3a9c4 100644 --- a/src/gt4py/next/program_processors/runners/dace_iterator/__init__.py +++ b/src/gt4py/next/program_processors/runners/dace_iterator/__init__.py @@ -17,6 +17,8 @@ except ModuleNotFoundError: import sys + if "pytest" in sys.modules: + raise print("Error, module dace not found", file=sys.stderr) exit() diff --git a/tests/next_tests/unit_tests/conftest.py b/tests/next_tests/unit_tests/conftest.py index a4157b31eb..2094c285c0 100644 --- a/tests/next_tests/unit_tests/conftest.py +++ b/tests/next_tests/unit_tests/conftest.py @@ -14,6 +14,7 @@ from __future__ import annotations +import sys from dataclasses import dataclass import pytest @@ -27,12 +28,18 @@ try: + import dace + + # import dace_iterator only if dace is available from gt4py.next.program_processors.runners import dace_iterator except ModuleNotFoundError as e: if "dace" in str(e): dace_iterator = None else: raise e +finally: + if dace_iterator: + del dace import next_tests