Skip to content

Commit

Permalink
Fixed logging-related test failure introduced by e79b857.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed Mar 27, 2013
1 parent f6989e5 commit 654d8e9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/logging_tests/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class WarningLoggerTests(TestCase):
and captured to the logging system and captured to the logging system
""" """
def setUp(self): 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
# to the logs.
logging.captureWarnings(True)

# this convoluted setup is to avoid printing this deprecation to # this convoluted setup is to avoid printing this deprecation to
# stderr during test running - as the test runner forces deprecations # stderr during test running - as the test runner forces deprecations
# to be displayed at the global py.warnings level # to be displayed at the global py.warnings level
Expand All @@ -108,6 +114,9 @@ def tearDown(self):
for i, handler in enumerate(self.logger.handlers): for i, handler in enumerate(self.logger.handlers):
self.logger.handlers[i].stream = self.old_streams[i] self.logger.handlers[i].stream = self.old_streams[i]


# Reset warnings state.
logging.captureWarnings(False)

@override_settings(DEBUG=True) @override_settings(DEBUG=True)
def test_warnings_capture(self): def test_warnings_capture(self):
warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', DeprecationWarning)
Expand Down

0 comments on commit 654d8e9

Please sign in to comment.