1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +00:00

Corrected YearComparisonLookup.get_bound() signature.

This commit is contained in:
Srinivas Reddy Thatiparthy 2017-09-04 19:47:51 +05:30 committed by Tim Graham
parent af35c69a3c
commit 0d3f567a7a
2 changed files with 18 additions and 1 deletions

View File

@ -509,7 +509,7 @@ class YearComparisonLookup(YearLookup):
def get_rhs_op(self, connection, rhs):
return connection.operators[self.lookup_name] % rhs
def get_bound(self):
def get_bound(self, start, finish):
raise NotImplementedError(
'subclasses of YearComparisonLookup must provide a get_bound() method'
)

View File

@ -0,0 +1,17 @@
from datetime import datetime
from django.db.models import Value
from django.db.models.fields import DateTimeField
from django.db.models.lookups import YearComparisonLookup
from django.test import SimpleTestCase
class YearComparisonLookupTests(SimpleTestCase):
def test_get_bound(self):
look_up = YearComparisonLookup(
lhs=Value(datetime(2010, 1, 1, 0, 0, 0), output_field=DateTimeField()),
rhs=Value(datetime(2010, 1, 1, 23, 59, 59), output_field=DateTimeField()),
)
msg = 'subclasses of YearComparisonLookup must provide a get_bound() method'
with self.assertRaisesMessage(NotImplementedError, msg):
look_up.get_bound(datetime(2010, 1, 1, 0, 0, 0), datetime(2010, 1, 1, 23, 59, 59))