2010-10-11 00:38:28 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
LOCALE='es_AR'
|
2010-10-11 00:38:28 +08:00
|
|
|
|
|
|
|
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)
|
2010-12-04 15:28:12 +08:00
|
|
|
self.assertFalse(os.path.exists(self.MO_FILE))
|