Skip to content

Commit

Permalink
skip module
Browse files Browse the repository at this point in the history
  • Loading branch information
baberabb committed Dec 30, 2024
1 parent 00feaf3 commit c34581e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/models/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit c34581e

Please sign in to comment.