diff options
| author | Daniyal <abbasi.daniyal98@gmail.com> | 2021-03-24 11:15:08 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-15 11:43:33 +0200 |
| commit | f479df7f8d03ab767bb5e5d655243191087d6432 (patch) | |
| tree | bf6f248ad7938a0d9f77ea616a59fba2d5a8befb /tests/datetimes/tests.py | |
| parent | 08f077888548a951f01b454d0db08d9407f7f0aa (diff) | |
Refs #32508 -- Raised Type/ValueError instead of using "assert" in django.db.models.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'tests/datetimes/tests.py')
| -rw-r--r-- | tests/datetimes/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/datetimes/tests.py b/tests/datetimes/tests.py index f42936b557..7f98032e0a 100644 --- a/tests/datetimes/tests.py +++ b/tests/datetimes/tests.py @@ -199,3 +199,16 @@ class DateTimesTests(TestCase): Article.objects.create(pub_date=dt, published_on=dt.date(), title="Don't put dates into datetime functions!") with self.assertRaisesMessage(ValueError, "Cannot truncate DateField 'published_on' to DateTimeField"): list(Article.objects.datetimes('published_on', 'second')) + + def test_datetimes_fails_when_given_invalid_kind_argument(self): + msg = ( + "'kind' must be one of 'year', 'month', 'week', 'day', 'hour', " + "'minute', or 'second'." + ) + with self.assertRaisesMessage(ValueError, msg): + Article.objects.datetimes('pub_date', 'bad_kind') + + def test_datetimes_fails_when_given_invalid_order_argument(self): + msg = "'order' must be either 'ASC' or 'DESC'." + with self.assertRaisesMessage(ValueError, msg): + Article.objects.datetimes('pub_date', 'year', order='bad order') |
