MCPcopy
hub / github.com/django/django / test_last

Method test_last

tests/get_earliest_or_latest/tests.py:213–224  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

211 )
212
213 def test_last(self):
214 p1 = Person.objects.create(name="Alice", birthday=datetime(1950, 1, 1))
215 p2 = Person.objects.create(name="Bob", birthday=datetime(1960, 2, 3))
216 # Note: by default PK ordering.
217 self.assertEqual(Person.objects.last(), p2)
218 self.assertEqual(Person.objects.order_by("-name").last(), p1)
219 self.assertEqual(
220 Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).last(), p1
221 )
222 self.assertIsNone(
223 Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).last()
224 )
225
226 def test_index_error_not_suppressed(self):
227 """

Callers

nothing calls this directly

Calls 4

lastMethod · 0.80
order_byMethod · 0.80
createMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected