Skip to content

Commit

Permalink
Fix the last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljodal committed Feb 1, 2022
1 parent 5c20283 commit dc224f9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion babel/messages/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ def python_format(self):
"""Whether the message contains Python-style parameters.
>>> Message('foo %(name)s bar').python_format
False
>>> Message('foo %(name)s bar', flags=['python-format']).python_format
True
>>> Message(('foo %(name)s', 'foo %(name)s')).python_format
>>> Message(('foo %(name)s', 'foo %(name)s'), flags=['python-format']).python_format
True
:type: `bool`"""
Expand Down
2 changes: 1 addition & 1 deletion babel/messages/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
>>> from io import BytesIO
>>> for message in extract('python', BytesIO(source)):
... print(message)
(3, u'Hello, world!', [], None)
(3, u'Hello, world!', [], None, set())
:param method: an extraction method (a callable), or
a string specifying the extraction method (.e.g. "python");
Expand Down
2 changes: 1 addition & 1 deletion babel/messages/pofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def write_po(fileobj, catalog, width=76, no_location=False, omit_header=False,
>>> catalog = Catalog()
>>> catalog.add(u'foo %(name)s', locations=[('main.py', 1)],
... flags=('fuzzy',))
... flags=('fuzzy', 'python-format'))
<Message...>
>>> catalog.add((u'bar', u'baz'), locations=[('main.py', 3)])
<Message...>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
msgid ""
msgstr ""

#, python-format
msgid "bar %(sign)s"
msgstr "tanko %(merkki)s"
6 changes: 4 additions & 2 deletions tests/messages/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ def test_message_pluralizable():


def test_message_python_format():
assert catalog.Message('foo %(name)s bar').python_format
assert catalog.Message(('foo %(name)s', 'foo %(name)s')).python_format
assert catalog.Message('foo %(name)s bar', flags={'python-format'}).python_format
assert catalog.Message(('foo %(name)s', 'foo %(name)s'), flags={'python-format'}).python_format
assert not catalog.Message('foo %(name)s bar').python_format
assert not catalog.Message(('foo %(name)s', 'foo %(name)s')).python_format


def test_catalog():
Expand Down

0 comments on commit dc224f9

Please sign in to comment.