mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Split tests.basic.ModelTests in several tests; refs #18586.
This commit is contained in:
parent
77c0a904cb
commit
7e2c804c94
5 changed files with 384 additions and 315 deletions
|
@ -2,7 +2,9 @@ from __future__ import unicode_literals
|
|||
|
||||
import datetime
|
||||
|
||||
from django.db.models.fields import FieldDoesNotExist
|
||||
from django.test import TestCase
|
||||
from django.utils import six
|
||||
|
||||
from .models import Article, Comment, Category
|
||||
|
||||
|
@ -81,3 +83,40 @@ class DatesTests(TestCase):
|
|||
],
|
||||
lambda d: d,
|
||||
)
|
||||
|
||||
def test_dates_fails_when_no_arguments_are_provided(self):
|
||||
self.assertRaises(
|
||||
TypeError,
|
||||
Article.objects.dates,
|
||||
)
|
||||
|
||||
def test_dates_fails_when_given_invalid_field_argument(self):
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
FieldDoesNotExist,
|
||||
"Article has no field named 'invalid_field'",
|
||||
Article.objects.dates,
|
||||
"invalid_field",
|
||||
"year",
|
||||
)
|
||||
|
||||
def test_dates_fails_when_given_invalid_kind_argument(self):
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
AssertionError,
|
||||
"'kind' must be one of 'year', 'month' or 'day'.",
|
||||
Article.objects.dates,
|
||||
"pub_date",
|
||||
"bad_kind",
|
||||
)
|
||||
|
||||
def test_dates_fails_when_given_invalid_order_argument(self):
|
||||
six.assertRaisesRegex(
|
||||
self,
|
||||
AssertionError,
|
||||
"'order' must be either 'ASC' or 'DESC'.",
|
||||
Article.objects.dates,
|
||||
"pub_date",
|
||||
"year",
|
||||
order="bad order",
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue