From 0d3f567a7ace9ca688712ffea9a396e118a4a697 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Mon, 4 Sep 2017 19:47:51 +0530 Subject: [PATCH] Corrected YearComparisonLookup.get_bound() signature. --- django/db/models/lookups.py | 2 +- tests/lookup/test_lookups.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/lookup/test_lookups.py diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py index 4c8e9e31fe..d82c29af66 100644 --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -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' ) diff --git a/tests/lookup/test_lookups.py b/tests/lookup/test_lookups.py new file mode 100644 index 0000000000..d327b472fc --- /dev/null +++ b/tests/lookup/test_lookups.py @@ -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))