Fixed #31314 -- Raised CommandError when locale is not specified in makemessages.
Regression in 0707b824fe
.
This commit is contained in:
parent
e908eb6287
commit
984531f96e
|
@ -329,7 +329,7 @@ class Command(BaseCommand):
|
||||||
exts = extensions or ['html', 'txt', 'py']
|
exts = extensions or ['html', 'txt', 'py']
|
||||||
self.extensions = handle_extensions(exts)
|
self.extensions = handle_extensions(exts)
|
||||||
|
|
||||||
if (locale is None and not exclude and not process_all) or self.domain is None:
|
if (not locale and not exclude and not process_all) or self.domain is None:
|
||||||
raise CommandError(
|
raise CommandError(
|
||||||
"Type '%s help %s' for usage information."
|
"Type '%s help %s' for usage information."
|
||||||
% (os.path.basename(sys.argv[0]), sys.argv[1])
|
% (os.path.basename(sys.argv[0]), sys.argv[1])
|
||||||
|
|
|
@ -142,6 +142,16 @@ class BasicExtractorTests(ExtractorTests):
|
||||||
self.assertIn('#. Translators: One-line translator comment #1', po_contents)
|
self.assertIn('#. Translators: One-line translator comment #1', po_contents)
|
||||||
self.assertIn('msgctxt "Special trans context #1"', po_contents)
|
self.assertIn('msgctxt "Special trans context #1"', po_contents)
|
||||||
|
|
||||||
|
def test_no_option(self):
|
||||||
|
# One of either the --locale, --exclude, or --all options is required.
|
||||||
|
msg = "Type 'manage.py help makemessages' for usage information."
|
||||||
|
with mock.patch(
|
||||||
|
'django.core.management.commands.makemessages.sys.argv',
|
||||||
|
['manage.py', 'makemessages'],
|
||||||
|
):
|
||||||
|
with self.assertRaisesRegex(CommandError, msg):
|
||||||
|
management.call_command('makemessages')
|
||||||
|
|
||||||
def test_comments_extractor(self):
|
def test_comments_extractor(self):
|
||||||
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
management.call_command('makemessages', locale=[LOCALE], verbosity=0)
|
||||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||||
|
|
Loading…
Reference in New Issue