test-env
tests/messages/data/project/i18n/en_US
tests/messages/data/project/i18n/long_messages.pot
-tests/messages/data/project/i18n/temp*
\ No newline at end of file
+tests/messages/data/project/i18n/temp*
+tests/messages/data/project/i18n/fi_BUGGY/LC_MESSAGES/*.mo
'or the base directory')
def run(self):
+ n_errors = 0
for domain in self.domain:
- self._run_domain(domain)
+ for catalog, errors in self._run_domain(domain).items():
+ n_errors += len(errors)
+ if n_errors:
+ self.log.error('%d errors encountered.' % n_errors)
+ return (1 if n_errors else 0)
def _run_domain(self, domain):
po_files = []
if not po_files:
raise DistutilsOptionError('no message catalogs found')
+ catalogs_and_errors = {}
+
for idx, (locale, po_file) in enumerate(po_files):
mo_file = mo_files[idx]
with open(po_file, 'rb') as infile:
self.log.info('catalog %s is marked as fuzzy, skipping', po_file)
continue
- for message, errors in catalog.check():
+ catalogs_and_errors[catalog] = catalog_errors = list(catalog.check())
+ for message, errors in catalog_errors:
for error in errors:
self.log.error(
'error: %s:%d: %s', po_file, message.lineno, error
with open(mo_file, 'wb') as outfile:
write_mo(outfile, catalog, use_fuzzy=self.use_fuzzy)
+ return catalogs_and_errors
+
class extract_messages(Command):
"""Message extraction command for use in ``setup.py`` scripts.
assert isinstance(cmdinst, extract_messages)
assert cmdinst.add_location == 'never'
assert cmdinst.no_location
+
+
+def test_extract_error_code(monkeypatch, capsys):
+ monkeypatch.chdir(project_dir)
+ cmdinst = configure_cli_command("compile --domain=messages --directory i18n --locale fi_BUGGY")
+ assert cmdinst.run() == 1
+ out, err = capsys.readouterr()
+ # replace hack below for py2/py3 compatibility
+ assert "unknown named placeholder 'merkki'" in err.replace("u'", "'")