diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-02-12 19:12:36 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-02-12 19:12:36 +0000 |
| commit | 179fefcf7c1e9c6f0a4db5b31a4444bee24e73fa (patch) | |
| tree | 8780b9d3be561215a98d21a212c1086927476d77 /tests | |
| parent | e1e3f243715c400bc6e2cec5bd650ac90ecb7f44 (diff) | |
Fixed #15286 -- Don't show deprecation warning if project locale dir is included in LOCALE_PATHS. Thanks to Claude and Ramiro.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15508 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/i18n/test_warnings.py | 32 | ||||
| -rw-r--r-- | tests/regressiontests/i18n/tests.py | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/regressiontests/i18n/test_warnings.py b/tests/regressiontests/i18n/test_warnings.py new file mode 100644 index 0000000000..519749252f --- /dev/null +++ b/tests/regressiontests/i18n/test_warnings.py @@ -0,0 +1,32 @@ +from os.path import join, normpath, abspath, dirname +import warnings + +import django +from django.conf import settings +from django.test.utils import get_warnings_state, restore_warnings_state +from django.utils.unittest import TestCase + + +class DeprecationWarningTests(TestCase): + + def setUp(self): + self.warning_state = get_warnings_state() + self.old_settings_module = settings.SETTINGS_MODULE + settings.SETTINGS_MODULE = 'regressiontests' + self.old_locale_paths = settings.LOCALE_PATHS + + def tearDown(self): + restore_warnings_state(self.warning_state) + settings.SETTINGS_MODULE = self.old_settings_module + settings.LOCALE_PATHS = self.old_locale_paths + + def test_no_warn_if_project_and_locale_paths_overlap(self): + """Test that PendingDeprecationWarning isn't generated when a deprecated project level locale/ subdir is also included in LOCALE_PATHS.""" + project_path = join(dirname(abspath(__file__)), '..') + settings.LOCALE_PATHS += (normpath(join(project_path, 'locale')),) + warnings.filterwarnings('error', "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.", PendingDeprecationWarning) + reload(django.utils.translation) + try: + django.utils.translation.ugettext('Time') + except PendingDeprecationWarning: + self.fail("PendingDeprecationWarning shouldn't be raised when settings/project locale and a LOCALE_PATHS member point to the same file system location.") diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index c9dc1fb45f..9a51b4139f 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -24,6 +24,7 @@ from models import Company, TestModel from commands.tests import * +from test_warnings import DeprecationWarningTests class TranslationTests(TestCase): |
