Fix flaky test_for_warning_if_padding_and_no_attention_mask (#24706)

fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2023-07-07 11:55:21 +02:00
committed by GitHub
parent fb78769b9c
commit 4957294270

View File

@@ -584,6 +584,9 @@ class BertModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
# Check for warnings if the attention_mask is missing. # Check for warnings if the attention_mask is missing.
logger = logging.get_logger("transformers.modeling_utils") logger = logging.get_logger("transformers.modeling_utils")
# clear cache so we can test the warning is emitted (from `warning_once`).
logger.warning_once.cache_clear()
with CaptureLogger(logger) as cl: with CaptureLogger(logger) as cl:
model = BertModel(config=config) model = BertModel(config=config)
model.to(torch_device) model.to(torch_device)