PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/i18n/commands/compilation.py

https://code.google.com/p/mango-py/
Python | 35 lines | 22 code | 10 blank | 3 comment | 0 complexity | 7954063bc1e0058da07cb3fb50619097 MD5 | raw file
 1import os
 2try:
 3    from cStringIO import StringIO
 4except ImportError:
 5    from StringIO import StringIO
 6
 7from django.core.management import CommandError
 8from django.core.management.commands.compilemessages import compile_messages
 9from django.test import TestCase
10
11LOCALE='es_AR'
12
13
14class MessageCompilationTests(TestCase):
15
16    MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE
17
18    def setUp(self):
19        self._cwd = os.getcwd()
20        self.test_dir = os.path.abspath(os.path.dirname(__file__))
21
22    def tearDown(self):
23        os.chdir(self._cwd)
24
25
26class PoFileTests(MessageCompilationTests):
27
28    def test_bom_rejection(self):
29        os.chdir(self.test_dir)
30        # We don't use the django.core.management intrastructure (call_command()
31        # et al) because CommandError's cause exit(1) there. We test the
32        # underlying compile_messages function instead
33        out = StringIO()
34        self.assertRaises(CommandError, compile_messages, out, locale=LOCALE)
35        self.assertFalse(os.path.exists(self.MO_FILE))