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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user