diff options
author | ruro <ruro.ruro@ya.ru> | 2021-06-15 13:56:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 13:56:16 +0300 |
commit | 96acf8688c0e4b96788fbc35bb6d1640ef46a091 (patch) | |
tree | 40c2ec4b4ae0caaf796f7f2ba883214080354bc2 /tests | |
parent | 7ebdf5a249ff8861bbcd3f7e4cc1ba9555c3fb65 (diff) | |
download | babel-96acf8688c0e4b96788fbc35bb6d1640ef46a091.tar.gz |
Implement `--init-missing` option for `pybabel update` (#785)
* implement update --init-missing option
* trivial test that the --init-missing option exists
* add non-trivial update --init-missing test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/messages/test_frontend.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 7058021..b56554c 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -1208,6 +1208,43 @@ compiling catalog %s to %s catalog = read_po(infp) assert len(catalog) == 4 # Catalog was updated + def test_update_init_missing(self): + template = Catalog() + template.add("1") + template.add("2") + template.add("3") + tmpl_file = os.path.join(i18n_dir, 'temp2-template.pot') + with open(tmpl_file, "wb") as outfp: + write_po(outfp, template) + po_file = os.path.join(i18n_dir, 'temp2.po') + + self.cli.run(sys.argv + ['update', + '--init-missing', + '-l', 'fi', + '-o', po_file, + '-i', tmpl_file]) + + with open(po_file, "r") as infp: + catalog = read_po(infp) + assert len(catalog) == 3 + + # Add another entry to the template + + template.add("4") + + with open(tmpl_file, "wb") as outfp: + write_po(outfp, template) + + self.cli.run(sys.argv + ['update', + '--init-missing', + '-l', 'fi_FI', + '-o', po_file, + '-i', tmpl_file]) + + with open(po_file, "r") as infp: + catalog = read_po(infp) + assert len(catalog) == 4 # Catalog was updated + def test_parse_mapping(): buf = StringIO( @@ -1351,8 +1388,9 @@ def test_extract_distutils_keyword_arg_388(kwarg, expected): def test_update_catalog_boolean_args(): - cmdinst = configure_cli_command("update --no-wrap -N --ignore-obsolete --previous -i foo -o foo -l en") + cmdinst = configure_cli_command("update --init-missing --no-wrap -N --ignore-obsolete --previous -i foo -o foo -l en") assert isinstance(cmdinst, update_catalog) + assert cmdinst.init_missing is True assert cmdinst.no_wrap is True assert cmdinst.no_fuzzy_matching is True assert cmdinst.ignore_obsolete is True |