mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Test Django 1.10
Also includes: * Change AnymailTestMixin.assertDoesNotWarn to filter specific warning classes. * Look specifically for AnymailInsecureWebhookWarning in WebhookBasicAuthTestsMixin.test_warns_if_no_auth (because we don't care *in that test case* about DeprecatedInDjango10 warnings).
This commit is contained in:
@@ -51,9 +51,15 @@ class AnymailTestMixin:
|
||||
return _AssertWarnsContext(expected_warning, self, expected_regex=expected_regex, msg=msg)
|
||||
|
||||
@contextmanager
|
||||
def assertDoesNotWarn(self):
|
||||
def assertDoesNotWarn(self, disallowed_warning=Warning):
|
||||
"""Makes test error (rather than fail) if disallowed_warning occurs.
|
||||
|
||||
Note: you probably want to be more specific than the default
|
||||
disallowed_warning=Warning, which errors for any warning
|
||||
(including DeprecationWarnings).
|
||||
"""
|
||||
try:
|
||||
warnings.simplefilter("error")
|
||||
warnings.simplefilter("error", disallowed_warning)
|
||||
yield
|
||||
finally:
|
||||
warnings.resetwarnings()
|
||||
|
||||
@@ -82,7 +82,7 @@ class WebhookBasicAuthTestsMixin(object):
|
||||
with self.assertWarns(AnymailInsecureWebhookWarning):
|
||||
response = self.call_webhook()
|
||||
else:
|
||||
with self.assertDoesNotWarn():
|
||||
with self.assertDoesNotWarn(AnymailInsecureWebhookWarning):
|
||||
response = self.call_webhook()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user