[1.10.x] Fixed #27309 -- Added CallableBool.__hash__().
Backport of 3ab55c1a8a
from master
This commit is contained in:
parent
67fd51a54f
commit
c473235bf6
|
@ -116,6 +116,9 @@ class CallableBool:
|
||||||
def __or__(self, other):
|
def __or__(self, other):
|
||||||
return bool(self.value or other)
|
return bool(self.value or other)
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.value)
|
||||||
|
|
||||||
CallableFalse = CallableBool(False)
|
CallableFalse = CallableBool(False)
|
||||||
CallableTrue = CallableBool(True)
|
CallableTrue = CallableBool(True)
|
||||||
|
|
||||||
|
|
|
@ -9,4 +9,5 @@ Django 1.10.3 fixes several bugs in 1.10.2.
|
||||||
Bugfixes
|
Bugfixes
|
||||||
========
|
========
|
||||||
|
|
||||||
* ...
|
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
|
||||||
|
tested for ``set`` membership (:ticket:`27309`).
|
||||||
|
|
|
@ -25,3 +25,7 @@ class TestCallableBool(SimpleTestCase):
|
||||||
self.assertIs(CallableTrue | False, True)
|
self.assertIs(CallableTrue | False, True)
|
||||||
self.assertIs(CallableFalse | True, True)
|
self.assertIs(CallableFalse | True, True)
|
||||||
self.assertFalse(CallableFalse | False, False)
|
self.assertFalse(CallableFalse | False, False)
|
||||||
|
|
||||||
|
def test_set_membership(self):
|
||||||
|
self.assertIs(CallableTrue in {True}, True)
|
||||||
|
self.assertIs(CallableFalse not in {True}, True)
|
||||||
|
|
Loading…
Reference in New Issue