mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Removed warnings level handling code as per deprecation TL.
This commit is contained in:
parent
e1dd24d2f6
commit
4f6be9a0c4
3 changed files with 0 additions and 75 deletions
|
@ -270,37 +270,6 @@ class AssertTemplateUsedContextManagerTests(TestCase):
|
|||
render_to_string('template_used/alternative.html')
|
||||
|
||||
|
||||
class SaveRestoreWarningState(TestCase):
|
||||
def test_save_restore_warnings_state(self):
|
||||
"""
|
||||
Ensure save_warnings_state/restore_warnings_state work correctly.
|
||||
"""
|
||||
# In reality this test could be satisfied by many broken implementations
|
||||
# of save_warnings_state/restore_warnings_state (e.g. just
|
||||
# warnings.resetwarnings()) , but it is difficult to test more.
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
|
||||
self.save_warnings_state()
|
||||
|
||||
class MyWarning(Warning):
|
||||
pass
|
||||
|
||||
# Add a filter that causes an exception to be thrown, so we can catch it
|
||||
warnings.simplefilter("error", MyWarning)
|
||||
self.assertRaises(Warning, lambda: warnings.warn("warn", MyWarning))
|
||||
|
||||
# Now restore.
|
||||
self.restore_warnings_state()
|
||||
# After restoring, we shouldn't get an exception. But we don't want a
|
||||
# warning printed either, so we have to silence the warning.
|
||||
warnings.simplefilter("ignore", MyWarning)
|
||||
warnings.warn("warn", MyWarning)
|
||||
|
||||
# Remove the filter we just added.
|
||||
self.restore_warnings_state()
|
||||
|
||||
|
||||
class HTMLEqualTests(TestCase):
|
||||
def test_html_parser(self):
|
||||
element = parse_html('<div><p>Hello</p></div>')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue