mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage().
This commit is contained in:
parent
7ba040de77
commit
704443acac
21 changed files with 210 additions and 285 deletions
7
tests/cache/tests.py
vendored
7
tests/cache/tests.py
vendored
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue