Skip to content

Commit

Permalink
fixup! fixup! Provide a way of checking if the catalogs are up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
kjagiello committed Jan 29, 2022
1 parent 30e120a commit 406b625
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion babel/messages/catalog.py
Expand Up @@ -147,7 +147,7 @@ def is_identical(self, other):
properties.
"""
assert isinstance(other, Message)
return self.__dict__ == self.__dict__
return self.__dict__ == other.__dict__

def clone(self):
return Message(*map(copy, (self.id, self.string, self.locations,
Expand Down
24 changes: 20 additions & 4 deletions tests/messages/test_frontend.py
Expand Up @@ -1218,22 +1218,20 @@ def test_check(self):
write_po(outfp, template)
po_file = os.path.join(i18n_dir, 'temp1.po')

# Update the catalog file
self.cli.run(sys.argv + ['update',
'-l', 'fi_FI',
'-o', po_file,
'-i', tmpl_file])

with open(po_file, "r") as infp:
original_catalog = read_po(infp)

# Run a check without introducing any changes to the template
self.cli.run(sys.argv + ['update',
'--check',
'-l', 'fi_FI',
'-o', po_file,
'-i', tmpl_file])

# Make a change to the template and expect a failure
# Add a new entry and expect the check to fail
template.add("4")
with open(tmpl_file, "wb") as outfp:
write_po(outfp, template)
Expand All @@ -1245,6 +1243,24 @@ def test_check(self):
'-o', po_file,
'-i', tmpl_file])

# Write the latest changes to the po-file
self.cli.run(sys.argv + ['update',
'-l', 'fi_FI',
'-o', po_file,
'-i', tmpl_file])

# Update an entry and expect the check to fail
template.add("4", locations=[("foo.py", 1)])
with open(tmpl_file, "wb") as outfp:
write_po(outfp, template)

with self.assertRaises(DistutilsError):
self.cli.run(sys.argv + ['update',
'--check',
'-l', 'fi_FI',
'-o', po_file,
'-i', tmpl_file])

def test_update_init_missing(self):
template = Catalog()
template.add("1")
Expand Down

0 comments on commit 406b625

Please sign in to comment.