summaryrefslogtreecommitdiff
path: root/tests/null_queries
diff options
context:
space:
mode:
Diffstat (limited to 'tests/null_queries')
-rw-r--r--tests/null_queries/tests.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/null_queries/tests.py b/tests/null_queries/tests.py
index 4c5c3bbe5c..828c68d921 100644
--- a/tests/null_queries/tests.py
+++ b/tests/null_queries/tests.py
@@ -44,9 +44,14 @@ class NullQueriesTests(TestCase):
with self.assertRaisesMessage(ValueError, "Cannot use None as a query value"):
Choice.objects.filter(id__gt=None)
- # Related managers use __exact=None implicitly if the object hasn't been saved.
- p2 = Poll(question="How?")
- self.assertEqual(repr(p2.choice_set.all()), "<QuerySet []>")
+ def test_unsaved(self):
+ poll = Poll(question="How?")
+ msg = (
+ "'Poll' instance needs to have a primary key value before this "
+ "relationship can be used."
+ )
+ with self.assertRaisesMessage(ValueError, msg):
+ poll.choice_set.all()
def test_reverse_relations(self):
"""