From 54ea290e5bbd19d87bd8dba807738eeeaf01a362 Mon Sep 17 00:00:00 2001 From: ElizabethU Date: Mon, 2 Sep 2019 19:09:31 -0700 Subject: Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons. Changed __eq__ to return NotImplemented instead of False if compared to an object of the same type, as is recommended by the Python data model reference. Now these models can be compared to ANY (or other objects with __eq__ overwritten) without returning False automatically. --- tests/model_indexes/tests.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/model_indexes') diff --git a/tests/model_indexes/tests.py b/tests/model_indexes/tests.py index ade27e1a4b..6a31109031 100644 --- a/tests/model_indexes/tests.py +++ b/tests/model_indexes/tests.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.conf import settings from django.db import connection, models from django.db.models.query_utils import Q @@ -28,6 +30,7 @@ class SimpleIndexesTests(SimpleTestCase): same_index.model = Book another_index.model = Book self.assertEqual(index, same_index) + self.assertEqual(index, mock.ANY) self.assertNotEqual(index, another_index) def test_index_fields_type(self): -- cgit v1.3