mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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.
This commit is contained in:
committed by
Mariusz Felisiak
parent
6475e6318c
commit
54ea290e5b
@@ -3,6 +3,7 @@ import pickle
|
||||
import unittest
|
||||
import uuid
|
||||
from copy import deepcopy
|
||||
from unittest import mock
|
||||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db import DatabaseError, connection, models
|
||||
@@ -965,6 +966,7 @@ class SimpleExpressionTests(SimpleTestCase):
|
||||
Expression(models.IntegerField()),
|
||||
Expression(output_field=models.IntegerField())
|
||||
)
|
||||
self.assertEqual(Expression(models.IntegerField()), mock.ANY)
|
||||
self.assertNotEqual(
|
||||
Expression(models.IntegerField()),
|
||||
Expression(models.CharField())
|
||||
|
||||
Reference in New Issue
Block a user