From c34581ec6cae397827bf2d5f628f2e5d11235f02 Mon Sep 17 00:00:00 2001 From: Baber Date: Mon, 30 Dec 2024 01:38:59 +0000 Subject: [PATCH] skip module --- tests/models/conftest.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/models/conftest.py b/tests/models/conftest.py index aa51321058..a070da5a8b 100644 --- a/tests/models/conftest.py +++ b/tests/models/conftest.py @@ -2,10 +2,19 @@ import pytest +# Check if the required component exists +has_encoder_decoder_cache = False try: from transformers import EncoderDecoderCache + + has_encoder_decoder_cache = True except ImportError: - pytest.skip( - "transformers.EncoderDecoderCache is required for model tests", - allow_module_level=True, - ) + pass + + +# Mark all tests in this directory as requiring encoder_decoder_cache +def pytest_collection_modifyitems(items): + skip_marker = pytest.mark.skip(reason="requires transformers.EncoderDecoderCache") + for item in items: + if not has_encoder_decoder_cache: + item.add_marker(skip_marker)