mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #373 -- Improved test coverage of tuple lookup checks.
This also removed unreachable checks.
This commit is contained in:
committed by
Sarah Boyce
parent
2a4321ba23
commit
347ab72c02
@@ -240,3 +240,28 @@ class TupleLookupsTests(TestCase):
|
||||
self.assertSequenceEqual(
|
||||
Contact.objects.filter(customer__isnull=subquery).order_by("id"), ()
|
||||
)
|
||||
|
||||
def test_lookup_errors(self):
|
||||
m_2_elements = "'%s' lookup of 'customer' field must have 2 elements"
|
||||
m_2_elements_each = "'in' lookup of 'customer' field must have 2 elements each"
|
||||
test_cases = (
|
||||
({"customer": 1}, m_2_elements % "exact"),
|
||||
({"customer": (1, 2, 3)}, m_2_elements % "exact"),
|
||||
({"customer__in": (1, 2, 3)}, m_2_elements_each),
|
||||
({"customer__in": ("foo", "bar")}, m_2_elements_each),
|
||||
({"customer__gt": 1}, m_2_elements % "gt"),
|
||||
({"customer__gt": (1, 2, 3)}, m_2_elements % "gt"),
|
||||
({"customer__gte": 1}, m_2_elements % "gte"),
|
||||
({"customer__gte": (1, 2, 3)}, m_2_elements % "gte"),
|
||||
({"customer__lt": 1}, m_2_elements % "lt"),
|
||||
({"customer__lt": (1, 2, 3)}, m_2_elements % "lt"),
|
||||
({"customer__lte": 1}, m_2_elements % "lte"),
|
||||
({"customer__lte": (1, 2, 3)}, m_2_elements % "lte"),
|
||||
)
|
||||
|
||||
for kwargs, message in test_cases:
|
||||
with (
|
||||
self.subTest(kwargs=kwargs),
|
||||
self.assertRaisesMessage(ValueError, message),
|
||||
):
|
||||
Contact.objects.get(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user