Skip to content

Commit

Permalink
TST Use plain asserts in tests (huggingface#1448)
Browse files Browse the repository at this point in the history
Use pytest style asserts instead of unittest methods.

Use `pytest.raises` and `pytest.warns` where suitable.
  • Loading branch information
akx authored and BenjaminBossan committed Mar 14, 2024
1 parent 6c51dca commit f8a45f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/testing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,11 @@ def _test_merge_layers_is_idempotent(self, model_id, config_cls, config_kwargs):

# merging again should not change anything
# also check warning:
with self.assertWarnsRegex(UserWarning, "All adapters are already merged, nothing to do"):
with pytest.warns(UserWarning, match="All adapters are already merged, nothing to do"):
model.merge_adapter()
logits_1 = model(**self.prepare_inputs_for_testing())[0]

self.assertTrue(torch.allclose(logits_0, logits_1, atol=1e-6, rtol=1e-6))
assert torch.allclose(logits_0, logits_1, atol=1e-6, rtol=1e-6)

def _test_generate(self, model_id, config_cls, config_kwargs):
model = self.transformers_class.from_pretrained(model_id)
Expand Down

0 comments on commit f8a45f0

Please sign in to comment.