Skip to content

[tests] migrate to unittest.assertEqual #10670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/transformers/speecht5/test_feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_attention_mask_target(self):
feat_dict["return_attention_mask"] = True
feat_extract = self.feature_extraction_class(**feat_dict)
speech_inputs = self.feat_extract_tester.prepare_inputs_for_target()
input_lenghts = [len(x) for x in speech_inputs]
input_lengths = [len(x) for x in speech_inputs]
input_name = feat_extract.model_input_names[0]

processed = BatchFeature({input_name: speech_inputs})
Expand All @@ -343,18 +343,18 @@ def test_attention_mask_target(self):
processed = feat_extract.pad(processed, padding="longest", return_tensors="np")
self.assertIn("attention_mask", processed)
self.assertListEqual(list(processed.attention_mask.shape), list(processed[input_name].shape[:2]))
self.assertListEqual(processed.attention_mask.sum(-1).tolist(), input_lenghts)
self.assertListEqual(processed.attention_mask.sum(-1).tolist(), input_lengths)

def test_attention_mask_with_truncation_target(self):
feat_dict = self.feat_extract_dict
feat_dict["return_attention_mask"] = True
feat_extract = self.feature_extraction_class(**feat_dict)
speech_inputs = self.feat_extract_tester.prepare_inputs_for_target()
input_lenghts = [len(x) for x in speech_inputs]
input_lengths = [len(x) for x in speech_inputs]
input_name = feat_extract.model_input_names[0]

processed = BatchFeature({input_name: speech_inputs})
max_length = min(input_lenghts)
max_length = min(input_lengths)

feat_extract.feature_size = feat_extract.num_mel_bins # hack!

Expand Down Expand Up @@ -393,7 +393,7 @@ def test_integration(self):
input_speech = self._load_datasamples(1)
feature_extractor = SpeechT5FeatureExtractor()
input_values = feature_extractor(input_speech, return_tensors="pd").input_values
self.assertEquals(input_values.shape, [1, 93680])
self.assertEqual(input_values.shape, [1, 93680])
self.assertTrue(paddle.allclose(input_values[0, :30], EXPECTED_INPUT_VALUES, atol=1e-6))

def test_integration_target(self):
Expand All @@ -409,5 +409,5 @@ def test_integration_target(self):
input_speech = self._load_datasamples(1)
feature_extractor = SpeechT5FeatureExtractor()
input_values = feature_extractor(audio_target=input_speech, return_tensors="pd").input_values
self.assertEquals(input_values.shape, [1, 366, 80])
self.assertEqual(input_values.shape, [1, 366, 80])
self.assertTrue(paddle.allclose(input_values[0, 0, :30], EXPECTED_INPUT_VALUES, atol=1e-4))
4 changes: 2 additions & 2 deletions tests/transformers/yuan/test_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def test_extract_non_learnable_parts(self):
context_data=context_data,
)
for idx, round in enumerate(conversation_result["conversations"]):
self.assertEquals(tokenizer.decode(round[0]), decode_outputs[idx][0])
self.assertEquals(tokenizer.decode(round[1]), decode_outputs[idx][1])
self.assertEqual(tokenizer.decode(round[0]), decode_outputs[idx][0])
self.assertEqual(tokenizer.decode(round[1]), decode_outputs[idx][1])
Loading