Kaydet (Commit) 0d3f567a authored tarafından Srinivas Reddy Thatiparthy's avatar Srinivas Reddy Thatiparthy Kaydeden (comit) Tim Graham

Corrected YearComparisonLookup.get_bound() signature.

üst af35c69a
...@@ -509,7 +509,7 @@ class YearComparisonLookup(YearLookup): ...@@ -509,7 +509,7 @@ class YearComparisonLookup(YearLookup):
def get_rhs_op(self, connection, rhs): def get_rhs_op(self, connection, rhs):
return connection.operators[self.lookup_name] % rhs return connection.operators[self.lookup_name] % rhs
def get_bound(self): def get_bound(self, start, finish):
raise NotImplementedError( raise NotImplementedError(
'subclasses of YearComparisonLookup must provide a get_bound() method' 'subclasses of YearComparisonLookup must provide a get_bound() method'
) )
......
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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment