From de413791aa580de0ad35ad1ee924cf44792ed0ae Mon Sep 17 00:00:00 2001 From: Itamar Oren Date: Wed, 9 Apr 2025 13:04:50 -0700 Subject: [PATCH] Fix deprecated unittest asserts in executorch Summary: In Python 3.2+, a number of asserts were deprecated in the unittest module: https://docs.python.org/3/library/unittest.html#deprecated-aliases. In Python 3.12, these asserts were deleted completely. The files in this diff still use the deprecated asserts. This codemod attempts to fix uses of the deprecated asserts, replacing them with non-deprecated equivalents. It is a naive codemod, using sed. Reviewed By: yilei Differential Revision: D72616610 --- backends/xnnpack/test/ops/test_check_quant_params.py | 2 +- examples/models/llava/test/test_llava.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backends/xnnpack/test/ops/test_check_quant_params.py b/backends/xnnpack/test/ops/test_check_quant_params.py index a04751ca5f1..d05b1fce540 100644 --- a/backends/xnnpack/test/ops/test_check_quant_params.py +++ b/backends/xnnpack/test/ops/test_check_quant_params.py @@ -65,7 +65,7 @@ def _test_check_quant_message(self, ep_modifier, expected_message): with self.assertRaises(ValueError) as context: to_edge_transform_and_lower(aten, partitioner=[XnnpackPartitioner()]) - self.assertEquals(str(context.exception), expected_message) + self.assertEqual(str(context.exception), expected_message) def test_in_per_tensor_quant(self): for invalid_scale in [ diff --git a/examples/models/llava/test/test_llava.py b/examples/models/llava/test/test_llava.py index 5fd60399415..36381b27124 100644 --- a/examples/models/llava/test/test_llava.py +++ b/examples/models/llava/test/test_llava.py @@ -131,7 +131,7 @@ def test_llava_export(self): # being tested, using llama_transformer new_tokens = [torch.argmax(pte_prefill_after_img).item()] # TODO: uncomment this line - # self.assertEquals(new_tokens[0], 1932) # When + # self.assertEqual(new_tokens[0], 1932) # When for i in range(4): print(i, llava_model.tokenizer.decode(new_tokens[i])) token_embeds = llava_module.run_method(