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

https://code.google.com/p/mango-py/ · Python · 35 lines · 22 code · 10 blank · 3 comment · 2 complexity · 7954063bc1e0058da07cb3fb50619097 MD5 · raw file

  1. import os
  2. try:
  3. from cStringIO import StringIO
  4. except ImportError:
  5. from StringIO import StringIO
  6. from django.core.management import CommandError
  7. from django.core.management.commands.compilemessages import compile_messages
  8. from django.test import TestCase
  9. LOCALE='es_AR'
  10. class MessageCompilationTests(TestCase):
  11. MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE
  12. def setUp(self):
  13. self._cwd = os.getcwd()
  14. self.test_dir = os.path.abspath(os.path.dirname(__file__))
  15. def tearDown(self):
  16. os.chdir(self._cwd)
  17. class PoFileTests(MessageCompilationTests):
  18. def test_bom_rejection(self):
  19. os.chdir(self.test_dir)
  20. # We don't use the django.core.management intrastructure (call_command()
  21. # et al) because CommandError's cause exit(1) there. We test the
  22. # underlying compile_messages function instead
  23. out = StringIO()
  24. self.assertRaises(CommandError, compile_messages, out, locale=LOCALE)
  25. self.assertFalse(os.path.exists(self.MO_FILE))