Added a test for the PendingDeprecationWarning introduced in r15441. Refs #14924, #15286.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15513 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales 2011-02-12 20:42:39 +00:00
parent 179fefcf7c
commit eaf17475b2
1 changed files with 12 additions and 1 deletions

View File

@ -20,11 +20,22 @@ class DeprecationWarningTests(TestCase):
settings.SETTINGS_MODULE = self.old_settings_module
settings.LOCALE_PATHS = self.old_locale_paths
def test_warn_if_project_has_locale_subdir(self):
"""Test that PendingDeprecationWarning is generated when a deprecated project level locale/ subdir is present."""
project_path = join(dirname(abspath(__file__)), '..')
warnings.filterwarnings('error',
"Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
PendingDeprecationWarning)
reload(django.utils.translation)
self.assertRaises(PendingDeprecationWarning, django.utils.translation.ugettext, 'Time')
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)
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')