mirror of
https://github.com/django/django.git
synced 2025-06-04 02:59:13 +00:00
Fixed #27154 -- Allowed comparing CallableBool with bitwise or.
Thanks Tim for the review.
This commit is contained in:
parent
b961b51eaf
commit
b7fb608142
@ -116,6 +116,9 @@ class CallableBool:
|
|||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return self.value != other
|
return self.value != other
|
||||||
|
|
||||||
|
def __or__(self, other):
|
||||||
|
return bool(self.value or other)
|
||||||
|
|
||||||
CallableFalse = CallableBool(False)
|
CallableFalse = CallableBool(False)
|
||||||
CallableTrue = CallableBool(True)
|
CallableTrue = CallableBool(True)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ Bugfixes
|
|||||||
doesn't return a result (:ticket:`26991`).
|
doesn't return a result (:ticket:`26991`).
|
||||||
|
|
||||||
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
|
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
|
||||||
compared using ``==`` and ``!=`` (:ticket:`26988`).
|
compared using ``==``, ``!=``, and ``|`` (:ticket:`26988`, :ticket:`27154`).
|
||||||
|
|
||||||
* Removed the broken ``BaseCommand.usage()`` method which was for
|
* Removed the broken ``BaseCommand.usage()`` method which was for
|
||||||
``optparse`` support (:ticket:`27000`).
|
``optparse`` support (:ticket:`27000`).
|
||||||
|
@ -14,3 +14,14 @@ class TestCallableBool(SimpleTestCase):
|
|||||||
self.assertEqual(CallableFalse, False)
|
self.assertEqual(CallableFalse, False)
|
||||||
self.assertFalse(CallableFalse != False) # noqa: E712
|
self.assertFalse(CallableFalse != False) # noqa: E712
|
||||||
self.assertNotEqual(CallableFalse, True)
|
self.assertNotEqual(CallableFalse, True)
|
||||||
|
|
||||||
|
def test_or(self):
|
||||||
|
self.assertIs(CallableTrue | CallableTrue, True)
|
||||||
|
self.assertIs(CallableTrue | CallableFalse, True)
|
||||||
|
self.assertIs(CallableFalse | CallableTrue, True)
|
||||||
|
self.assertIs(CallableFalse | CallableFalse, False)
|
||||||
|
|
||||||
|
self.assertIs(CallableTrue | True, True)
|
||||||
|
self.assertIs(CallableTrue | False, True)
|
||||||
|
self.assertIs(CallableFalse | True, True)
|
||||||
|
self.assertFalse(CallableFalse | False, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user