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/postgres_tests/test_constraints.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/postgres_tests/test_constraints.py') diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py index d8665f59f6..b22821294a 100644 --- a/tests/postgres_tests/test_constraints.py +++ b/tests/postgres_tests/test_constraints.py @@ -1,4 +1,5 @@ import datetime +from unittest import mock from django.db import connection, transaction from django.db.models import F, Func, Q @@ -175,6 +176,7 @@ class ExclusionConstraintTests(PostgreSQLTestCase): condition=Q(cancelled=False), ) self.assertEqual(constraint_1, constraint_1) + self.assertEqual(constraint_1, mock.ANY) self.assertNotEqual(constraint_1, constraint_2) self.assertNotEqual(constraint_1, constraint_3) self.assertNotEqual(constraint_2, constraint_3) -- cgit v1.3