From c59aa9e6aa0b90bc8d4f8e9be0079c3c5b901879 Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Wed, 28 Mar 2018 15:03:56 +0200 Subject: [PATCH] Added test for combining Q objects with non-Q objects. --- tests/queries/test_q.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/queries/test_q.py b/tests/queries/test_q.py index 9e71553ef7..9adff07ef2 100644 --- a/tests/queries/test_q.py +++ b/tests/queries/test_q.py @@ -19,6 +19,14 @@ class QTests(SimpleTestCase): def test_combine_or_both_empty(self): self.assertEqual(Q() | Q(), Q()) + def test_combine_not_q_object(self): + obj = object() + q = Q(x=1) + with self.assertRaisesMessage(TypeError, str(obj)): + q | obj + with self.assertRaisesMessage(TypeError, str(obj)): + q & obj + def test_deconstruct(self): q = Q(price__gt=F('discounted_price')) path, args, kwargs = q.deconstruct()