Merge remote-tracking branch 'ptone/18985-fix'

This commit is contained in:
Jacob Kaplan-Moss 2013-03-27 10:31:54 -05:00
commit f6989e559c
6 changed files with 40 additions and 22 deletions

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python
import logging
import os
import shutil
import subprocess
@ -82,6 +83,14 @@ def setup(verbosity, test_labels):
settings.LANGUAGE_CODE = 'en'
settings.SITE_ID = 1
if verbosity > 0:
# Ensure any warnings captured to logging are piped through a verbose
# logging handler. If any -W options were passed explicitly on command
# line, warnings are not captured, and this has no effect.
logger = logging.getLogger('py.warnings')
handler = logging.StreamHandler()
logger.addHandler(handler)
# Load all the ALWAYS_INSTALLED_APPS.
get_apps()

View file

@ -2,6 +2,8 @@ import warnings
from django.test import TestCase
warnings.warn("module-level warning from deprecation_app", DeprecationWarning)
class DummyTest(TestCase):
def test_warn(self):
warnings.warn("warning from test", DeprecationWarning)

View file

@ -299,7 +299,8 @@ class DeprecationDisplayTest(AdminScriptTestCase):
def test_runner_deprecation_verbosity_default(self):
args = ['test', '--settings=test_project.settings']
out, err = self.run_django_admin(args)
self.assertTrue("DeprecationWarning: warning from test" in err)
self.assertIn("DeprecationWarning: warning from test", err)
self.assertIn("DeprecationWarning: module-level warning from deprecation_app", err)
@unittest.skipIf(sys.version_info[:2] == (2, 6),
"On Python 2.6, DeprecationWarnings are visible anyway")