From ac2908ebeac7d3e8f5e0fa4b56385e14f8949e3e Mon Sep 17 00:00:00 2001 From: ddundo Date: Mon, 14 Oct 2024 18:20:49 +0000 Subject: [PATCH] #222: Fix cache error in tests --- test/conftest.py | 6 ++++-- test_adjoint/conftest.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index bb45c5cf..d1fed9eb 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -24,5 +24,7 @@ def pytest_runtest_teardown(item, nextitem): from firedrake.tsfc_interface import TSFCKernel from pyop2.global_kernel import GlobalKernel - TSFCKernel._cache.clear() - GlobalKernel._cache.clear() + if hasattr(TSFCKernel, "_cache"): + TSFCKernel._cache.clear() + if hasattr(GlobalKernel, "_cache"): + GlobalKernel._cache.clear() diff --git a/test_adjoint/conftest.py b/test_adjoint/conftest.py index 8a582c51..4a91951a 100644 --- a/test_adjoint/conftest.py +++ b/test_adjoint/conftest.py @@ -138,8 +138,10 @@ def pytest_runtest_teardown(item, nextitem): from firedrake.tsfc_interface import TSFCKernel from pyop2.global_kernel import GlobalKernel - TSFCKernel._cache.clear() - GlobalKernel._cache.clear() + if hasattr(TSFCKernel, "_cache"): + TSFCKernel._cache.clear() + if hasattr(GlobalKernel, "_cache"): + GlobalKernel._cache.clear() @pytest.fixture(autouse=True)