def test_inequality(self): cond = iter(generate_conditions()) cond = iter(zip(cond, cond)) for conditions1, conditions2 in zip(cond, cond): qs1 = (Q(**conditions1[0]), Q(**conditions1[1])) qs2 = (Q(**conditions2[0]), Q(**conditions2[1])) assert_not_equal(Union(*qs1), Union(*qs2))
def test_inversion_inversion(self): q = Q(foo=42) assert_is(~~q, q)
def test_q_intersection(self): q = Q(foo=42) & Q(bar=42) eq_(q, Q(foo=42, bar=42)) assert_is_instance(q, Q)
def test_intersection_query_with_its_inversion(self): q = Query() self.check_both(q, ~q, ~Q())
def test_intersection_nothing(self): self.check_both(~Q(), Query(), ~Q())
def test_inequality(self): args = iter(((None, ), (0, ), (0, 3), (0, 3, 2))) for s1, s2 in zip(args, args): assert_not_equal(Slice(Q(), slice(*s1)), Slice(Q(), slice(*s2)))
def test_with_everything(self): self.check_both(Q(), Query(), Q())
def test_repr(self): for conditions in generate_conditions(): q = ~Q(**conditions) eq_(q, eval(repr(q)))
def test_repr(self): for fields in ((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')): q = Q().order_by(*fields) eq_(q, eval(repr(q)))
def test_q(self): matching = [2, 3, 5, 7] q = Q() q.match = lambda obj_cache, pk: pk in matching self.assert_execute(q, matching)
def test_inequality(self): args = iter(((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz'))) for fields1, fields2 in zip(args, args): assert_not_equal(Ordered(Q(), *fields1), Ordered(Q(), *fields2))
def test_equality(self): for fields in ((), ('foo', ), ('foo', '-bar'), ('foo', '-bar', 'baz')): eq_(Ordered(Q(), *fields), Ordered(Q(), *fields))
def test_repr(self): for s in ((None, ), (0, ), (0, 3), (0, 3, 2)): q = Q()[slice(*s)] eq_(q, eval(repr(q)))
def test_equality(self): for conditions in generate_conditions(): q = Q(**conditions) eq_(Inversion(q), Inversion(q))
def test_with_nothing(self): q = Query() self.check_both(~Q(), q, q)
def test_inequality(self): cond = iter(generate_conditions()) for conditions1, conditions2 in zip(cond, cond): assert_not_equal(~Q(**conditions1), ~Q(**conditions2))
def test_equality(self): for conditions in generate_conditions(): eq_(Q(**conditions), Q(**conditions))
def test_equality(self): cond = iter(generate_conditions()) for conditions1, conditions2 in zip(cond, cond): qs = (Q(**conditions1), Q(**conditions2)) eq_(Union(*qs), Union(*qs))
def test_intersection_everything(self): q = Query() self.check_both(Q(), q, q)
def test_repr(self): cond = iter(generate_conditions()) for conditions1, conditions2 in zip(cond, cond): q = Q(**conditions1) & Q(**conditions2) eq_(q, eval(repr(q)))
def test_equality(self): for s in ((None, ), (0, ), (0, 3), (0, 3, 2)): eq_(Slice(Q(), slice(*s)), Slice(Q(), slice(*s)))