1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed typo in DistanceLookupBase.process_rhs() error message.

This commit is contained in:
Sergey Fedoseev 2017-07-19 22:40:56 +05:00 committed by Tim Graham
parent 196da41ee2
commit 3f7953846e
2 changed files with 9 additions and 7 deletions

View File

@ -306,7 +306,7 @@ class DistanceLookupBase(GISLookup):
if not isinstance(self.rhs, (tuple, list)) or not 2 <= len(self.rhs) <= 4:
raise ValueError("2, 3, or 4-element tuple required for '%s' lookup." % self.lookup_name)
elif len(self.rhs) == 4 and not self.rhs[3] == 'spheroid':
raise ValueError("For 4-element tuples the last argument must be the 'speroid' directive.")
raise ValueError("For 4-element tuples the last argument must be the 'spheroid' directive.")
# Check if the second parameter is a band index.
if len(self.rhs) > 2 and not self.rhs[2] == 'spheroid':

View File

@ -140,15 +140,17 @@ class DistanceTest(TestCase):
expected_cities.pop(0)
self.assertEqual(expected_cities, self.get_names(dist_qs))
# Too many params (4 in this case) should raise a ValueError.
queryset = AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4'))
with self.assertRaises(ValueError):
len(queryset)
msg = "2, 3, or 4-element tuple required for 'distance_lte' lookup."
with self.assertRaisesMessage(ValueError, msg): # Too many params.
len(AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4', None)))
# Not enough params should raise a ValueError.
with self.assertRaises(ValueError):
with self.assertRaisesMessage(ValueError, msg): # Too few params.
len(AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)',)))
msg = "For 4-element tuples the last argument must be the 'spheroid' directive."
with self.assertRaisesMessage(ValueError, msg):
len(AustraliaCity.objects.filter(point__distance_lte=('POINT(5 23)', D(km=100), 'spheroid', '4')))
# Getting all cities w/in 550 miles of Hobart.
hobart = AustraliaCity.objects.get(name='Hobart')
qs = AustraliaCity.objects.exclude(name='Hobart').filter(point__distance_lte=(hobart.point, D(mi=550)))