1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00
django/tests/lookup/test_timefield.py
Hasan Ramezani 3f7b327562 Fixed #31235 -- Made assertQuerysetEqual() compare querysets directly.
This also replaces assertQuerysetEqual() to
assertSequenceEqual()/assertCountEqual() where appropriate.

Co-authored-by: Peter Inglesby <peter.inglesby@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-11-06 09:24:50 +01:00

32 lines
845 B
Python

from django.test import TestCase
from .models import Alarm
class TimeFieldLookupTests(TestCase):
@classmethod
def setUpTestData(self):
# Create a few Alarms
self.al1 = Alarm.objects.create(desc='Early', time='05:30')
self.al2 = Alarm.objects.create(desc='Late', time='10:00')
self.al3 = Alarm.objects.create(desc='Precise', time='12:34:56')
def test_hour_lookups(self):
self.assertSequenceEqual(
Alarm.objects.filter(time__hour=5),
[self.al1],
)
def test_minute_lookups(self):
self.assertSequenceEqual(
Alarm.objects.filter(time__minute=30),
[self.al1],
)
def test_second_lookups(self):
self.assertSequenceEqual(
Alarm.objects.filter(time__second=56),
[self.al3],
)