1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.5.x] Fixed #19546 - ensure that deprecation warnings are shown during tests

refs #18985
This commit is contained in:
Preston Holmes
2013-01-02 16:00:39 -08:00
parent 7c39e041b1
commit af8e858c15
6 changed files with 59 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import logging
import unittest as real_unittest
from django.conf import settings
@@ -365,7 +366,19 @@ class DjangoTestSuiteRunner(object):
self.setup_test_environment()
suite = self.build_suite(test_labels, extra_tests)
old_config = self.setup_databases()
if self.verbosity > 0:
# ensure that deprecation warnings are displayed during testing
# the following state is assumed:
# logging.capturewarnings is true
# a "default" level warnings filter has been added for
# DeprecationWarning. See django.conf.LazySettings._configure_logging
logger = logging.getLogger('py.warnings')
handler = logging.StreamHandler()
logger.addHandler(handler)
result = self.run_suite(suite)
if self.verbosity > 0:
# remove the testing-specific handler
logger.removeHandler(handler)
self.teardown_databases(old_config)
self.teardown_test_environment()
return self.suite_result(suite, result)