From 39a72125e7671a1029b8e8c3a72a52ab1d59d4e4 Mon Sep 17 00:00:00 2001 From: Arthur <48595927+ArthurZucker@users.noreply.github.com> Date: Mon, 28 Nov 2022 17:08:57 +0100 Subject: [PATCH] fix both failing RoCBert tests (#20469) --- tests/models/roc_bert/test_modeling_roc_bert.py | 2 +- tests/models/roc_bert/test_tokenization_roc_bert.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/models/roc_bert/test_modeling_roc_bert.py b/tests/models/roc_bert/test_modeling_roc_bert.py index 1f814a17b2..bc7893b9c5 100644 --- a/tests/models/roc_bert/test_modeling_roc_bert.py +++ b/tests/models/roc_bert/test_modeling_roc_bert.py @@ -710,4 +710,4 @@ class RoCBertModelIntegrationTest(unittest.TestCase): # convert to tokens is: ['[CLS]', '巴', '*', '黎', '是', '法', '国', '的', '首', '都', '[SEP]'] expected_output = torch.tensor([[101, 2349, 115, 7944, 3221, 3791, 1744, 4638, 7674, 6963, 102]]) - self.assertEqual(output_ids, expected_output) + assert torch.allclose(output_ids, expected_output) diff --git a/tests/models/roc_bert/test_tokenization_roc_bert.py b/tests/models/roc_bert/test_tokenization_roc_bert.py index 7784032674..334a347a1e 100644 --- a/tests/models/roc_bert/test_tokenization_roc_bert.py +++ b/tests/models/roc_bert/test_tokenization_roc_bert.py @@ -299,8 +299,8 @@ class BertTokenizationTest(TokenizerTesterMixin, unittest.TestCase): encoded_sentence = tokenizer.build_inputs_with_special_tokens(text) encoded_pair = tokenizer.build_inputs_with_special_tokens(text, text_2) - assert encoded_sentence == [101] + text + [102] - assert encoded_pair == [101] + text + [102] + text_2 + [102] + assert encoded_sentence == [1] + text + [2] + assert encoded_pair == [1] + text + [2] + text_2 + [2] def test_prepare_for_model(self): tokenizers = self.get_tokenizers(do_lower_case=False)