From 9a45e58673b6183ef36b5802645664ba708df0f3 Mon Sep 17 00:00:00 2001 From: 954 <510485871@qq.com> Date: Sun, 17 Aug 2025 14:42:00 +0800 Subject: [PATCH] Updated the test to handle memoryview. --- tests/admin_filters/tests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py index b4968b5a48..ff2a647648 100644 --- a/tests/admin_filters/tests.py +++ b/tests/admin_filters/tests.py @@ -2073,7 +2073,7 @@ class ListFiltersTests(TestCase): try: choice = select_by(choices, "display", str(datas)) except IndexError as e: - raise IndexError(f"IndexError: {e}, choices={choices}") + raise IndexError(f"{e}, choices={choices}") self.assertEqual( choice["query_string"], "?datas=%s" % (quote(str(datas)),), @@ -2087,8 +2087,12 @@ class ListFiltersTests(TestCase): filter_changelist = filter_modeladmin.get_changelist_instance(filter_request) queryset = filter_changelist.get_queryset(filter_request) result = list(queryset) - self.assertEqual(len(result), 1) - self.assertEqual(result[0].datas, datas) + result_datas = ( + result[0].datas.tobytes() + if isinstance(result[0].datas, memoryview) + else result[0].datas + ) + self.assertEqual(result_datas, datas) class FacetsMixinTests(SimpleTestCase):