Implement __bool__ on Q and QCombination

This commit is contained in:
Filip Kucharczyk
2019-12-05 00:21:03 +01:00
parent 78b240b740
commit cb77bb6b69
3 changed files with 28 additions and 5 deletions

View File

@@ -407,6 +407,17 @@ class TestQ(unittest.TestCase):
def test_combine_or_both_empty(self):
assert Q() | Q() == Q()
def test_q_bool(self):
assert Q(name="John")
assert not Q()
def test_combine_bool(self):
assert not Q() & Q()
assert Q() & Q(name="John")
assert Q(name="John") & Q()
assert Q() | Q(name="John")
assert Q(name="John") | Q()
if __name__ == "__main__":
unittest.main()