summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-05-27 23:11:27 +0200
committerClaude Paroz <claude@2xlibre.net>2012-05-27 23:11:27 +0200
commitc3b56c7cdde661464da4aaa72cafb11c9260d754 (patch)
treec495187109e080d9f62322ee1425575905c6ea8d
parentcc4b4d9fd34d9b601de0bafaa3c1f249729fa49a (diff)
downloaddjango-c3b56c7cdde661464da4aaa72cafb11c9260d754.tar.gz
Used call_command in i18n compilation tests.
Now that call_command does not raise SystemExit any more, we can use call_command again for testing compilemessages.
-rw-r--r--tests/regressiontests/i18n/commands/compilation.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/tests/regressiontests/i18n/commands/compilation.py b/tests/regressiontests/i18n/commands/compilation.py
index 039e463d0b..d88e1feef6 100644
--- a/tests/regressiontests/i18n/commands/compilation.py
+++ b/tests/regressiontests/i18n/commands/compilation.py
@@ -1,8 +1,7 @@
import os
from io import BytesIO
-from django.core.management import CommandError
-from django.core.management.commands.compilemessages import compile_messages
+from django.core.management import call_command, CommandError
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import translation
@@ -25,11 +24,9 @@ class PoFileTests(MessageCompilationTests):
def test_bom_rejection(self):
os.chdir(test_dir)
- # We don't use the django.core.management infrastructure (call_command()
- # et al) because CommandError's cause exit(1) there. We test the
- # underlying compile_messages function instead
- out = BytesIO()
- self.assertRaises(CommandError, compile_messages, out, locale=self.LOCALE)
+ with self.assertRaisesRegexp(CommandError,
+ "file has a BOM \(Byte Order Mark\)"):
+ call_command('compilemessages', locale=self.LOCALE, stderr=BytesIO())
self.assertFalse(os.path.exists(self.MO_FILE))
@@ -45,11 +42,7 @@ class PoFileContentsTests(MessageCompilationTests):
def test_percent_symbol_in_po_file(self):
os.chdir(test_dir)
- # We don't use the django.core.management infrastructure (call_command()
- # et al) because CommandError's cause exit(1) there. We test the
- # underlying compile_messages function instead
- out = BytesIO()
- compile_messages(out, locale=self.LOCALE)
+ call_command('compilemessages', locale=self.LOCALE, stderr=BytesIO())
self.assertTrue(os.path.exists(self.MO_FILE))
@@ -64,11 +57,7 @@ class PercentRenderingTests(MessageCompilationTests):
def test_percent_symbol_escaping(self):
from django.template import Template, Context
os.chdir(test_dir)
- # We don't use the django.core.management infrastructure (call_command()
- # et al) because CommandError's cause exit(1) there. We test the
- # underlying compile_messages function instead
- out = BytesIO()
- compile_messages(out, locale=self.LOCALE)
+ call_command('compilemessages', locale=self.LOCALE, stderr=BytesIO())
with translation.override(self.LOCALE):
t = Template('{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}')
rendered = t.render(Context({}))