2016-08-02 21:32:00 +08:00
|
|
|
from django.test import SimpleTestCase
|
|
|
|
from django.utils.deprecation import CallableFalse, CallableTrue
|
|
|
|
|
|
|
|
|
|
|
|
class TestCallableBool(SimpleTestCase):
|
|
|
|
def test_true(self):
|
|
|
|
self.assertTrue(CallableTrue)
|
|
|
|
self.assertEqual(CallableTrue, True)
|
|
|
|
self.assertFalse(CallableTrue != True) # noqa: E712
|
|
|
|
self.assertNotEqual(CallableTrue, False)
|
|
|
|
|
|
|
|
def test_false(self):
|
|
|
|
self.assertFalse(CallableFalse)
|
|
|
|
self.assertEqual(CallableFalse, False)
|
|
|
|
self.assertFalse(CallableFalse != False) # noqa: E712
|
|
|
|
self.assertNotEqual(CallableFalse, True)
|
2016-08-31 16:07:30 +08:00
|
|
|
|
|
|
|
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)
|