summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-01-01 22:55:50 +0100
committerClaude Paroz <claude@2xlibre.net>2014-01-01 22:59:12 +0100
commitb2d78939d171f12ae7baaf0a2fa5a29b43bb2e47 (patch)
treeb2bfb606d2c697c1a3a1b9ea3c709f977ce32a31
parent1386075f62dfdee4584e76e7d86dff72f5d3c7ed (diff)
Prevented calling setup() inside catch_warnings
When django.setup() (and then configure_logging) is called inside catch_warnings, logging setup is negatively affected (notably warnings.showwarning definition).
-rw-r--r--tests/logging_tests/tests.py4
-rwxr-xr-xtests/runtests.py9
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index f020bfddef..5b536f9e82 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -91,8 +91,8 @@ class WarningLoggerTests(TestCase):
"""
def setUp(self):
# If tests are invoke with "-Wall" (or any -W flag actually) then
- # warning logging gets disabled (see django/conf/__init__.py). However,
- # these tests expect warnings to be logged, so manually force warnings
+ # warning logging gets disabled (see configure_logging in django/utils/log.py).
+ # However, these tests expect warnings to be logged, so manually force warnings
# to the logs. Use getattr() here because the logging capture state is
# undocumented and (I assume) brittle.
self._old_capture_state = bool(getattr(logging, '_warnings_showwarning', False))
diff --git a/tests/runtests.py b/tests/runtests.py
index e33533a083..bb14a27fd6 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -125,10 +125,13 @@ def setup(verbosity, test_labels):
handler = logging.StreamHandler()
logger.addHandler(handler)
+ warnings.filterwarnings(
+ 'ignore',
+ 'django.contrib.comments is deprecated and will be removed before Django 1.8.',
+ DeprecationWarning
+ )
# Load all the ALWAYS_INSTALLED_APPS.
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', DeprecationWarning)
- django.setup()
+ django.setup()
# Load all the test model apps.
test_modules = get_test_modules()