summaryrefslogtreecommitdiff
path: root/tests/get_earliest_or_latest
diff options
context:
space:
mode:
authorMorgan Aubert <morgan.aubert@impakfinance.com>2018-04-27 17:18:15 -0400
committerTim Graham <timograham@gmail.com>2018-05-09 11:40:28 -0400
commit704443acacf0dfbcb1c52df4b260585055754ce7 (patch)
tree600147bf6114d7b490fcd253ff9797b7e7531c09 /tests/get_earliest_or_latest
parent7ba040de7703fd06b9b35ddd31da40103d911c30 (diff)
downloaddjango-704443acacf0dfbcb1c52df4b260585055754ce7.tar.gz
Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage().
Diffstat (limited to 'tests/get_earliest_or_latest')
-rw-r--r--tests/get_earliest_or_latest/tests.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/get_earliest_or_latest/tests.py b/tests/get_earliest_or_latest/tests.py
index 62f6f85ce2..a49dc43402 100644
--- a/tests/get_earliest_or_latest/tests.py
+++ b/tests/get_earliest_or_latest/tests.py
@@ -1,7 +1,7 @@
-import warnings
from datetime import datetime
from django.test import TestCase
+from django.utils.deprecation import RemovedInDjango30Warning
from .models import Article, IndexErrorArticle, Person
@@ -169,16 +169,12 @@ class EarliestOrLatestTests(TestCase):
def test_field_name_kwarg_deprecation(self):
Person.objects.create(name='Deprecator', birthday=datetime(1950, 1, 1))
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter('always')
- Person.objects.latest(field_name='birthday')
-
- self.assertEqual(len(warns), 1)
- self.assertEqual(
- str(warns[0].message),
+ msg = (
'The field_name keyword argument to earliest() and latest() '
- 'is deprecated in favor of passing positional arguments.',
+ 'is deprecated in favor of passing positional arguments.'
)
+ with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
+ Person.objects.latest(field_name='birthday')
class TestFirstLast(TestCase):