summaryrefslogtreecommitdiff
path: root/tests/timezones
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2016-09-10 11:36:27 +0200
committerTim Graham <timograham@gmail.com>2016-09-13 10:07:37 -0400
commit0c1f71635f8a3f32195e1573fe929c7d88a78511 (patch)
tree4d8127fde3634dfd3d4ad8451cee140d34070821 /tests/timezones
parent8b050cf9dcad3db39cc9ef44906bfc39f5aa3d25 (diff)
downloaddjango-0c1f71635f8a3f32195e1573fe929c7d88a78511.tar.gz
Fixed #27203 -- Replaced assertQuerysetEqual(..., lambda o: o) with assertSequenceEqual().
Diffstat (limited to 'tests/timezones')
-rw-r--r--tests/timezones/tests.py115
1 files changed, 50 insertions, 65 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
index 13a19cc58d..e72fff069b 100644
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -200,42 +200,30 @@ class LegacyDatabaseTests(TestCase):
def test_query_datetimes(self):
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0))
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0))
- self.assertQuerysetEqual(
- Event.objects.datetimes('dt', 'year'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
- Event.objects.datetimes('dt', 'month'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
- Event.objects.datetimes('dt', 'day'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ self.assertSequenceEqual(Event.objects.datetimes('dt', 'year'), [datetime.datetime(2011, 1, 1, 0, 0, 0)])
+ self.assertSequenceEqual(Event.objects.datetimes('dt', 'month'), [datetime.datetime(2011, 1, 1, 0, 0, 0)])
+ self.assertSequenceEqual(Event.objects.datetimes('dt', 'day'), [datetime.datetime(2011, 1, 1, 0, 0, 0)])
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'hour'),
[datetime.datetime(2011, 1, 1, 1, 0, 0),
- datetime.datetime(2011, 1, 1, 4, 0, 0)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 4, 0, 0)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'minute'),
[datetime.datetime(2011, 1, 1, 1, 30, 0),
- datetime.datetime(2011, 1, 1, 4, 30, 0)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 4, 30, 0)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'second'),
[datetime.datetime(2011, 1, 1, 1, 30, 0),
- datetime.datetime(2011, 1, 1, 4, 30, 0)],
- transform=lambda d: d)
+ datetime.datetime(2011, 1, 1, 4, 30, 0)]
+ )
def test_raw_sql(self):
# Regression test for #17755
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
event = Event.objects.create(dt=dt)
- self.assertQuerysetEqual(
- Event.objects.raw('SELECT * FROM timezones_event WHERE dt = %s', [dt]),
- [event],
- transform=lambda d: d)
+ self.assertSequenceEqual(list(Event.objects.raw('SELECT * FROM timezones_event WHERE dt = %s', [dt])), [event])
def test_cursor_execute_accepts_naive_datetime(self):
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
@@ -469,78 +457,75 @@ class NewDatabaseTests(TestCase):
def test_query_datetimes(self):
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
- self.assertQuerysetEqual(
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'year'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'month'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'day'),
- [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ [datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=EAT)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'hour'),
[datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=EAT),
- datetime.datetime(2011, 1, 1, 4, 0, 0, tzinfo=EAT)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 4, 0, 0, tzinfo=EAT)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'minute'),
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
- datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'second'),
[datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT),
- datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)],
- transform=lambda d: d)
+ datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT)]
+ )
@skipUnlessDBFeature('has_zoneinfo_database')
def test_query_datetimes_in_other_timezone(self):
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0, tzinfo=EAT))
with timezone.override(UTC):
- self.assertQuerysetEqual(
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'year'),
[datetime.datetime(2010, 1, 1, 0, 0, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'month'),
[datetime.datetime(2010, 12, 1, 0, 0, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'day'),
[datetime.datetime(2010, 12, 31, 0, 0, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 0, 0, 0, tzinfo=UTC)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'hour'),
[datetime.datetime(2010, 12, 31, 22, 0, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=UTC)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 1, 0, 0, tzinfo=UTC)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'minute'),
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
- transform=lambda d: d)
- self.assertQuerysetEqual(
+ datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)]
+ )
+ self.assertSequenceEqual(
Event.objects.datetimes('dt', 'second'),
[datetime.datetime(2010, 12, 31, 22, 30, 0, tzinfo=UTC),
- datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)],
- transform=lambda d: d)
+ datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=UTC)]
+ )
def test_raw_sql(self):
# Regression test for #17755
dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
event = Event.objects.create(dt=dt)
- self.assertQuerysetEqual(
- Event.objects.raw('SELECT * FROM timezones_event WHERE dt = %s', [dt]),
- [event],
- transform=lambda d: d)
+ self.assertSequenceEqual(list(Event.objects.raw('SELECT * FROM timezones_event WHERE dt = %s', [dt])), [event])
@skipUnlessDBFeature('supports_timezones')
def test_cursor_execute_accepts_aware_datetime(self):