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/basic/tests.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/basic/tests.py') diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 89f6048c96..5eada343e1 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -1,5 +1,6 @@ import threading from datetime import datetime, timedelta +from unittest import mock from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections, models @@ -354,6 +355,7 @@ class ModelTest(TestCase): self.assertNotEqual(object(), Article(id=1)) a = Article() self.assertEqual(a, a) + self.assertEqual(a, mock.ANY) self.assertNotEqual(Article(), a) def test_hash(self): -- cgit v1.3