Skip to content

Instantly share code, notes, and snippets.

@claudep
Created August 2, 2016 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudep/78351dd6bbd5a53a04afc7dcd2f985bc to your computer and use it in GitHub Desktop.
Save claudep/78351dd6bbd5a53a04afc7dcd2f985bc to your computer and use it in GitHub Desktop.
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 48b5737..145adf5 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2483,6 +2483,19 @@ class ToFieldTests(TestCase):
[node1]
)
+ def test_isnull_query(self):
+ apple = Food.objects.create(name="apple")
+ lunch_food = Eaten.objects.create(food=apple, meal="lunch")
+ lunch_no_food = Eaten.objects.create(meal="lunch")
+ list(Eaten.objects.filter(food__isnull=False))
+ self.assertQuerysetEqual(
+ Eaten.objects.filter(food__isnull=False),
+ ['<Eaten: apple at lunch>']
+ )
+ self.assertQuerysetEqual(
+ Eaten.objects.filter(food__isnull=True),
+ ['<Eaten: None at lunch>']
+ )
class ConditionalTests(BaseQuerysetTest):
"""Tests whose execution depend on different environment conditions like
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment