~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to tests/regressiontests/i18n/test_warnings.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (1.1.21) (4.4.27 sid)
  • Revision ID: package-import@ubuntu.com-20130509151047-aqv8d71oj9wvcv8c
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import warnings
2
 
from os.path import join, normpath, abspath, dirname
3
 
 
4
 
import django
5
 
from django.conf import settings
6
 
from django.test.utils import get_warnings_state, restore_warnings_state
7
 
from django.utils.translation import _trans
8
 
from django.utils.unittest import TestCase
9
 
 
10
 
 
11
 
class DeprecationWarningTests(TestCase):
12
 
 
13
 
    def setUp(self):
14
 
        self.warning_state = get_warnings_state()
15
 
        self.old_settings_module = settings.SETTINGS_MODULE
16
 
        settings.SETTINGS_MODULE = 'regressiontests'
17
 
        self.old_locale_paths = settings.LOCALE_PATHS
18
 
 
19
 
    def tearDown(self):
20
 
        restore_warnings_state(self.warning_state)
21
 
        settings.SETTINGS_MODULE = self.old_settings_module
22
 
        settings.LOCALE_PATHS = self.old_locale_paths
23
 
 
24
 
    def test_warn_if_project_has_locale_subdir(self):
25
 
        """Test that DeprecationWarning is generated when a deprecated project level locale/ subdir is present."""
26
 
        project_path = join(dirname(abspath(__file__)), '..')
27
 
        warnings.filterwarnings('error',
28
 
                "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
29
 
                DeprecationWarning)
30
 
        _trans.__dict__ = {}
31
 
        self.assertRaises(DeprecationWarning, django.utils.translation.ugettext, 'Time')
32
 
 
33
 
    def test_no_warn_if_project_and_locale_paths_overlap(self):
34
 
        """Test that DeprecationWarning isn't generated when a deprecated project level locale/ subdir is also included in LOCALE_PATHS."""
35
 
        project_path = join(dirname(abspath(__file__)), '..')
36
 
        settings.LOCALE_PATHS += (normpath(join(project_path, 'locale')),)
37
 
        warnings.filterwarnings('error',
38
 
                "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
39
 
                DeprecationWarning)
40
 
        _trans.__dict__ = {}
41
 
        try:
42
 
            django.utils.translation.ugettext('Time')
43
 
        except DeprecationWarning:
44
 
            self.fail("DeprecationWarning shouldn't be raised when settings/project locale and a LOCALE_PATHS member point to the same file system location.")