Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage().

This commit is contained in:
Morgan Aubert 2018-04-27 17:18:15 -04:00 committed by Tim Graham
parent 7ba040de77
commit 704443acac
21 changed files with 210 additions and 285 deletions

View file

@ -10,7 +10,6 @@ import tempfile
import threading
import time
import unittest
import warnings
from unittest import mock
from django.conf import settings
@ -632,12 +631,8 @@ class BaseCacheTests:
cache.key_func = func
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with self.assertWarnsMessage(CacheKeyWarning, expected_warning):
cache.set(key, 'value')
self.assertEqual(len(w), 1)
self.assertIsInstance(w[0].message, CacheKeyWarning)
self.assertEqual(str(w[0].message.args[0]), expected_warning)
finally:
cache.key_func = old_func