summaryrefslogtreecommitdiff
path: root/tests/regressiontests/i18n/commands/compilation.py
blob: 44bb2f6ab4ec96974dee8b48898086fe6416c92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

from django.core.management import CommandError
from django.core.management.commands.compilemessages import compile_messages
from django.test import TestCase

LOCALE='es_AR'


class MessageCompilationTests(TestCase):

    MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE

    def setUp(self):
        self._cwd = os.getcwd()
        self.test_dir = os.path.abspath(os.path.dirname(__file__))

    def tearDown(self):
        os.chdir(self._cwd)


class PoFileTests(MessageCompilationTests):

    def test_bom_rejection(self):
        os.chdir(self.test_dir)
        # We don't use the django.core.management intrastructure (call_command()
        # et al) because CommandError's cause exit(1) there. We test the
        # underlying compile_messages function instead
        out = StringIO()
        self.assertRaises(CommandError, compile_messages, out, locale=LOCALE)
        self.assertFalse(os.path.exists(self.MO_FILE))