1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.

This commit is contained in:
za
2016-10-27 14:53:39 +07:00
committed by Tim Graham
parent 4bb70cbcc6
commit 321e94fa41
185 changed files with 1216 additions and 1528 deletions

View File

@@ -51,11 +51,11 @@ class EarliestOrLatestTests(TestCase):
self.assertEqual(Article.objects.filter(
pub_date__gt=datetime(2005, 7, 26)).earliest('expire_date'), a2)
# Ensure that earliest() overrides any other ordering specified on the
# query. Refs #11283.
# earliest() overrides any other ordering specified on the query.
# Refs #11283.
self.assertEqual(Article.objects.order_by('id').earliest(), a1)
# Ensure that error is raised if the user forgot to add a get_latest_by
# Error is raised if the user forgot to add a get_latest_by
# in the Model.Meta
Article.objects.model._meta.get_latest_by = None
with self.assertRaisesMessage(
@@ -103,11 +103,10 @@ class EarliestOrLatestTests(TestCase):
a3,
)
# Ensure that latest() overrides any other ordering specified on the query. Refs #11283.
# latest() overrides any other ordering specified on the query (#11283).
self.assertEqual(Article.objects.order_by('id').latest(), a4)
# Ensure that error is raised if the user forgot to add a get_latest_by
# in the Model.Meta
# Error is raised if get_latest_by isn't in Model.Meta.
Article.objects.model._meta.get_latest_by = None
with self.assertRaisesMessage(
AssertionError,
@@ -131,33 +130,19 @@ class TestFirstLast(TestCase):
def test_first(self):
p1 = Person.objects.create(name="Bob", birthday=datetime(1950, 1, 1))
p2 = Person.objects.create(name="Alice", birthday=datetime(1961, 2, 3))
self.assertEqual(
Person.objects.first(), p1)
self.assertEqual(
Person.objects.order_by('name').first(), p2)
self.assertEqual(
Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).first(),
p1)
self.assertIs(
Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).first(),
None)
self.assertEqual(Person.objects.first(), p1)
self.assertEqual(Person.objects.order_by('name').first(), p2)
self.assertEqual(Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).first(), p1)
self.assertIsNone(Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).first())
def test_last(self):
p1 = Person.objects.create(
name="Alice", birthday=datetime(1950, 1, 1))
p2 = Person.objects.create(
name="Bob", birthday=datetime(1960, 2, 3))
p1 = Person.objects.create(name="Alice", birthday=datetime(1950, 1, 1))
p2 = Person.objects.create(name="Bob", birthday=datetime(1960, 2, 3))
# Note: by default PK ordering.
self.assertEqual(
Person.objects.last(), p2)
self.assertEqual(
Person.objects.order_by('-name').last(), p1)
self.assertEqual(
Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).last(),
p1)
self.assertIs(
Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).last(),
None)
self.assertEqual(Person.objects.last(), p2)
self.assertEqual(Person.objects.order_by('-name').last(), p1)
self.assertEqual(Person.objects.filter(birthday__lte=datetime(1955, 1, 1)).last(), p1)
self.assertIsNone(Person.objects.filter(birthday__lte=datetime(1940, 1, 1)).last())
def test_index_error_not_suppressed(self):
"""