diff options
| author | Preston Holmes <preston@ptone.com> | 2013-03-24 21:34:46 -0700 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2013-03-27 10:37:47 -0500 |
| commit | 572a300e56bc0192a9c82565a1d39b96f18bebee (patch) | |
| tree | 9f592257a3b11cd5804e522ae6bcacc88211192c /tests | |
| parent | 456d6c15dbbfc81c355e790c15cda3c28205123e (diff) | |
[1.5.x] Fixed #18985 -- ensure module level deprecations are displayed
Also don't compete with -W CLI option.
Thanks to Aymeric Augustin for the catch, and Claude Paroz for the patch.
Backport of e79b857a07905340556f781a7d63016236b21c61 from master.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/test_runner/deprecation_app/tests.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/test_runner/tests.py | 3 | ||||
| -rwxr-xr-x | tests/runtests.py | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/tests/regressiontests/test_runner/deprecation_app/tests.py b/tests/regressiontests/test_runner/deprecation_app/tests.py index e676c3e3d5..6dee0888ec 100644 --- a/tests/regressiontests/test_runner/deprecation_app/tests.py +++ b/tests/regressiontests/test_runner/deprecation_app/tests.py @@ -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) diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py index 5df421c54b..b5e4a1d80a 100644 --- a/tests/regressiontests/test_runner/tests.py +++ b/tests/regressiontests/test_runner/tests.py @@ -298,7 +298,8 @@ class DeprecationDisplayTest(AdminScriptTestCase): def test_runner_deprecation_verbosity_default(self): args = ['test', '--settings=regressiontests.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") diff --git a/tests/runtests.py b/tests/runtests.py index 8c56e273b5..00bb852340 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import logging import os import shutil import subprocess @@ -106,6 +107,14 @@ def setup(verbosity, test_labels): # in our tests. settings.MANAGERS = ("admin@djangoproject.com",) + 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. # (This import statement is intentionally delayed until after we # access settings because of the USE_I18N dependency.) |
