Loading django/utils/deprecation.py +3 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ class RemovedInDjango18Warning(DeprecationWarning): pass RemovedInNextVersionWarning = RemovedInDjango18Warning class warn_about_renamed_method(object): def __init__(self, class_name, old_method_name, new_method_name, deprecation_warning): self.class_name = class_name Loading django/utils/log.py +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import warnings from django.conf import settings from django.core import mail from django.core.mail import get_connection from django.utils.deprecation import RemovedInNextVersionWarning from django.utils.module_loading import import_string from django.views.debug import ExceptionReporter, get_exception_reporter_filter Loading Loading @@ -68,8 +69,9 @@ def configure_logging(logging_config, logging_settings): if not sys.warnoptions: # Route warnings through python logging logging.captureWarnings(True) # Allow DeprecationWarnings through the warnings filters warnings.simplefilter("default", DeprecationWarning) # RemovedInNextVersionWarning is a subclass of DeprecationWarning which # is hidden by default, hence we force the "default" behavior warnings.simplefilter("default", RemovedInNextVersionWarning) if logging_config: # First find the logging configuration function ... Loading tests/logging_tests/tests.py +5 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from django.core import mail from django.test import TestCase, RequestFactory, override_settings from django.test.utils import patch_logger from django.utils.encoding import force_text from django.utils.deprecation import RemovedInNextVersionWarning from django.utils.log import (CallbackFilter, RequireDebugFalse, RequireDebugTrue) from django.utils.six import StringIO Loading Loading @@ -86,8 +87,8 @@ class DefaultLoggingTest(TestCase): class WarningLoggerTests(TestCase): """ Tests that warnings output for DeprecationWarnings is enabled and captured to the logging system Tests that warnings output for RemovedInDjangoXXWarning (XX being the next Django version) is enabled and captured to the logging system """ def setUp(self): # If tests are invoke with "-Wall" (or any -W flag actually) then Loading Loading @@ -118,12 +119,12 @@ class WarningLoggerTests(TestCase): @override_settings(DEBUG=True) def test_warnings_capture(self): warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', RemovedInNextVersionWarning) output = force_text(self.outputs[0].getvalue()) self.assertTrue('Foo Deprecated' in output) def test_warnings_capture_debug_false(self): warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', RemovedInNextVersionWarning) output = force_text(self.outputs[0].getvalue()) self.assertFalse('Foo Deprecated' in output) Loading tests/test_runner/tests.py +4 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from django import db from django.test import runner, TestCase, TransactionTestCase, skipUnlessDBFeature from django.test.testcases import connections_support_transactions from django.test.utils import IgnoreAllDeprecationWarningsMixin, override_system_checks from django.utils import six from admin_scripts.tests import AdminScriptTestCase from .models import Person Loading Loading @@ -368,14 +369,14 @@ class DeprecationDisplayTest(AdminScriptTestCase): args = ['test', '--settings=test_project.settings', 'test_runner_deprecation_app'] out, err = self.run_django_admin(args) self.assertIn("Ran 1 test", err) self.assertIn("DeprecationWarning: warning from test", err) self.assertIn("DeprecationWarning: module-level warning from deprecation_app", err) six.assertRegex(self, err, r"RemovedInDjango\d\dWarning: warning from test") six.assertRegex(self, err, r"RemovedInDjango\d\dWarning: module-level warning from deprecation_app") def test_runner_deprecation_verbosity_zero(self): args = ['test', '--settings=test_project.settings', '--verbosity=0', 'test_runner_deprecation_app'] out, err = self.run_django_admin(args) self.assertIn("Ran 1 test", err) self.assertFalse("DeprecationWarning: warning from test" in err) self.assertFalse("warning from test" in err) class AutoIncrementResetTest(TransactionTestCase): Loading tests/test_runner_deprecation_app/tests.py +3 −2 Original line number Diff line number Diff line import warnings from django.test import TestCase from django.utils.deprecation import RemovedInNextVersionWarning warnings.warn("module-level warning from deprecation_app", DeprecationWarning) warnings.warn("module-level warning from deprecation_app", RemovedInNextVersionWarning) class DummyTest(TestCase): def test_warn(self): warnings.warn("warning from test", DeprecationWarning) warnings.warn("warning from test", RemovedInNextVersionWarning) Loading
django/utils/deprecation.py +3 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ class RemovedInDjango18Warning(DeprecationWarning): pass RemovedInNextVersionWarning = RemovedInDjango18Warning class warn_about_renamed_method(object): def __init__(self, class_name, old_method_name, new_method_name, deprecation_warning): self.class_name = class_name Loading
django/utils/log.py +4 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import warnings from django.conf import settings from django.core import mail from django.core.mail import get_connection from django.utils.deprecation import RemovedInNextVersionWarning from django.utils.module_loading import import_string from django.views.debug import ExceptionReporter, get_exception_reporter_filter Loading Loading @@ -68,8 +69,9 @@ def configure_logging(logging_config, logging_settings): if not sys.warnoptions: # Route warnings through python logging logging.captureWarnings(True) # Allow DeprecationWarnings through the warnings filters warnings.simplefilter("default", DeprecationWarning) # RemovedInNextVersionWarning is a subclass of DeprecationWarning which # is hidden by default, hence we force the "default" behavior warnings.simplefilter("default", RemovedInNextVersionWarning) if logging_config: # First find the logging configuration function ... Loading
tests/logging_tests/tests.py +5 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from django.core import mail from django.test import TestCase, RequestFactory, override_settings from django.test.utils import patch_logger from django.utils.encoding import force_text from django.utils.deprecation import RemovedInNextVersionWarning from django.utils.log import (CallbackFilter, RequireDebugFalse, RequireDebugTrue) from django.utils.six import StringIO Loading Loading @@ -86,8 +87,8 @@ class DefaultLoggingTest(TestCase): class WarningLoggerTests(TestCase): """ Tests that warnings output for DeprecationWarnings is enabled and captured to the logging system Tests that warnings output for RemovedInDjangoXXWarning (XX being the next Django version) is enabled and captured to the logging system """ def setUp(self): # If tests are invoke with "-Wall" (or any -W flag actually) then Loading Loading @@ -118,12 +119,12 @@ class WarningLoggerTests(TestCase): @override_settings(DEBUG=True) def test_warnings_capture(self): warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', RemovedInNextVersionWarning) output = force_text(self.outputs[0].getvalue()) self.assertTrue('Foo Deprecated' in output) def test_warnings_capture_debug_false(self): warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', RemovedInNextVersionWarning) output = force_text(self.outputs[0].getvalue()) self.assertFalse('Foo Deprecated' in output) Loading
tests/test_runner/tests.py +4 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from django import db from django.test import runner, TestCase, TransactionTestCase, skipUnlessDBFeature from django.test.testcases import connections_support_transactions from django.test.utils import IgnoreAllDeprecationWarningsMixin, override_system_checks from django.utils import six from admin_scripts.tests import AdminScriptTestCase from .models import Person Loading Loading @@ -368,14 +369,14 @@ class DeprecationDisplayTest(AdminScriptTestCase): args = ['test', '--settings=test_project.settings', 'test_runner_deprecation_app'] out, err = self.run_django_admin(args) self.assertIn("Ran 1 test", err) self.assertIn("DeprecationWarning: warning from test", err) self.assertIn("DeprecationWarning: module-level warning from deprecation_app", err) six.assertRegex(self, err, r"RemovedInDjango\d\dWarning: warning from test") six.assertRegex(self, err, r"RemovedInDjango\d\dWarning: module-level warning from deprecation_app") def test_runner_deprecation_verbosity_zero(self): args = ['test', '--settings=test_project.settings', '--verbosity=0', 'test_runner_deprecation_app'] out, err = self.run_django_admin(args) self.assertIn("Ran 1 test", err) self.assertFalse("DeprecationWarning: warning from test" in err) self.assertFalse("warning from test" in err) class AutoIncrementResetTest(TransactionTestCase): Loading
tests/test_runner_deprecation_app/tests.py +3 −2 Original line number Diff line number Diff line import warnings from django.test import TestCase from django.utils.deprecation import RemovedInNextVersionWarning warnings.warn("module-level warning from deprecation_app", DeprecationWarning) warnings.warn("module-level warning from deprecation_app", RemovedInNextVersionWarning) class DummyTest(TestCase): def test_warn(self): warnings.warn("warning from test", DeprecationWarning) warnings.warn("warning from test", RemovedInNextVersionWarning)