Refs #23919 -- Removed reset_warning_registry() workaround for Python < 3.4.2.
This commit is contained in:
parent
56aee8d59f
commit
e5c67f0991
|
@ -768,20 +768,6 @@ def captured_stdin():
|
||||||
return captured_output("stdin")
|
return captured_output("stdin")
|
||||||
|
|
||||||
|
|
||||||
def reset_warning_registry():
|
|
||||||
"""
|
|
||||||
Clear warning registry for all modules. This is required in some tests
|
|
||||||
because of a bug in Python that prevents warnings.simplefilter("always")
|
|
||||||
from always making warnings appear: http://bugs.python.org/issue4180
|
|
||||||
|
|
||||||
The bug was fixed in Python 3.4.2.
|
|
||||||
"""
|
|
||||||
key = "__warningregistry__"
|
|
||||||
for mod in sys.modules.values():
|
|
||||||
if hasattr(mod, key):
|
|
||||||
getattr(mod, key).clear()
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def freeze_time(t):
|
def freeze_time(t):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.test.utils import reset_warning_registry
|
|
||||||
from django.utils.deprecation import (
|
from django.utils.deprecation import (
|
||||||
DeprecationInstanceCheck, RemovedInNextVersionWarning, RenameMethodsBase,
|
DeprecationInstanceCheck, RemovedInNextVersionWarning, RenameMethodsBase,
|
||||||
)
|
)
|
||||||
|
@ -24,7 +23,6 @@ class RenameMethodsTests(SimpleTestCase):
|
||||||
Ensure a warning is raised upon class definition to suggest renaming
|
Ensure a warning is raised upon class definition to suggest renaming
|
||||||
the faulty method.
|
the faulty method.
|
||||||
"""
|
"""
|
||||||
reset_warning_registry()
|
|
||||||
with warnings.catch_warnings(record=True) as recorded:
|
with warnings.catch_warnings(record=True) as recorded:
|
||||||
warnings.simplefilter('always')
|
warnings.simplefilter('always')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue