Refs #21429 -- Added SimpleTestCase.assertNoLogs() on Python < 3.10.

This commit is contained in:
François Freitag 2021-01-07 17:54:40 +01:00 committed by Mariusz Felisiak
parent d3ecef26b9
commit 7ca7f4495b
9 changed files with 82 additions and 19 deletions

View file

@ -177,9 +177,8 @@ class MiddlewareNotUsedTests(SimpleTestCase):
MIDDLEWARE=['middleware_exceptions.tests.MyMiddleware'],
)
def test_do_not_log_when_debug_is_false(self):
with self.assertRaisesMessage(AssertionError, 'no logs'):
with self.assertLogs('django.request', 'DEBUG'):
self.client.get('/middleware_exceptions/view/')
with self.assertNoLogs('django.request', 'DEBUG'):
self.client.get('/middleware_exceptions/view/')
@override_settings(MIDDLEWARE=[
'middleware_exceptions.middleware.SyncAndAsyncMiddleware',