diff options
author | Aarni Koskela <akx@iki.fi> | 2023-01-18 20:59:35 +0200 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-01-18 21:20:51 +0200 |
commit | 5f7580d40523ce8aa67f51a3eb941dc81faa47f2 (patch) | |
tree | fd92fba1f801935c8e21bbfa601c98e74890fa75 /tests/messages | |
parent | 65d9ae36ecb9d4a4691ffb9f21f3ff11e6ff5739 (diff) | |
download | babel-5f7580d40523ce8aa67f51a3eb941dc81faa47f2.tar.gz |
Apply ruff UP025 (unicode literal prefix) fix
Diffstat (limited to 'tests/messages')
-rw-r--r-- | tests/messages/test_catalog.py | 40 | ||||
-rw-r--r-- | tests/messages/test_extract.py | 38 | ||||
-rw-r--r-- | tests/messages/test_js_extract.py | 28 | ||||
-rw-r--r-- | tests/messages/test_jslexer.py | 6 | ||||
-rw-r--r-- | tests/messages/test_mofile.py | 16 | ||||
-rw-r--r-- | tests/messages/test_pofile.py | 82 |
6 files changed, 105 insertions, 105 deletions
diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py index eb1e308..29cfc0d 100644 --- a/tests/messages/test_catalog.py +++ b/tests/messages/test_catalog.py @@ -89,33 +89,33 @@ class CatalogTestCase(unittest.TestCase): def test_update_message_changed_to_plural(self): cat = catalog.Catalog() - cat.add(u'foo', u'Voh') + cat.add('foo', 'Voh') tmpl = catalog.Catalog() - tmpl.add((u'foo', u'foos')) + tmpl.add(('foo', 'foos')) cat.update(tmpl) assert cat['foo'].string == ('Voh', '') assert cat['foo'].fuzzy def test_update_message_changed_to_simple(self): cat = catalog.Catalog() - cat.add(u'foo' u'foos', (u'Voh', u'Vöhs')) + cat.add('foo' u'foos', ('Voh', 'Vöhs')) tmpl = catalog.Catalog() - tmpl.add(u'foo') + tmpl.add('foo') cat.update(tmpl) assert cat['foo'].string == 'Voh' assert cat['foo'].fuzzy def test_update_message_updates_comments(self): cat = catalog.Catalog() - cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 5)]) + cat['foo'] = catalog.Message('foo', locations=[('main.py', 5)]) assert cat['foo'].auto_comments == [] assert cat['foo'].user_comments == [] # Update cat[u'foo'] with a new location and a comment - cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 7)], + cat['foo'] = catalog.Message('foo', locations=[('main.py', 7)], user_comments=['Foo Bar comment 1']) assert cat['foo'].user_comments == ['Foo Bar comment 1'] # now add yet another location with another comment - cat[u'foo'] = catalog.Message('foo', locations=[('main.py', 9)], + cat['foo'] = catalog.Message('foo', locations=[('main.py', 9)], auto_comments=['Foo Bar comment 2']) assert cat['foo'].auto_comments == ['Foo Bar comment 2'] @@ -404,21 +404,21 @@ def test_catalog_plural_forms(): def test_catalog_setitem(): cat = catalog.Catalog() - cat[u'foo'] = catalog.Message(u'foo') - assert cat[u'foo'].id == 'foo' + cat['foo'] = catalog.Message('foo') + assert cat['foo'].id == 'foo' cat = catalog.Catalog() - cat[u'foo'] = catalog.Message(u'foo', locations=[('main.py', 1)]) - assert cat[u'foo'].locations == [('main.py', 1)] - cat[u'foo'] = catalog.Message(u'foo', locations=[('utils.py', 5)]) - assert cat[u'foo'].locations == [('main.py', 1), ('utils.py', 5)] + cat['foo'] = catalog.Message('foo', locations=[('main.py', 1)]) + assert cat['foo'].locations == [('main.py', 1)] + cat['foo'] = catalog.Message('foo', locations=[('utils.py', 5)]) + assert cat['foo'].locations == [('main.py', 1), ('utils.py', 5)] def test_catalog_add(): cat = catalog.Catalog() - foo = cat.add(u'foo') + foo = cat.add('foo') assert foo.id == 'foo' - assert cat[u'foo'] is foo + assert cat['foo'] is foo def test_catalog_update(): @@ -427,9 +427,9 @@ def test_catalog_update(): template.add('blue', locations=[('main.py', 100)]) template.add(('salad', 'salads'), locations=[('util.py', 42)]) cat = catalog.Catalog(locale='de_DE') - cat.add('blue', u'blau', locations=[('main.py', 98)]) - cat.add('head', u'Kopf', locations=[('util.py', 33)]) - cat.add(('salad', 'salads'), (u'Salat', u'Salate'), + cat.add('blue', 'blau', locations=[('main.py', 98)]) + cat.add('head', 'Kopf', locations=[('util.py', 33)]) + cat.add(('salad', 'salads'), ('Salat', 'Salate'), locations=[('util.py', 38)]) cat.update(template) @@ -440,11 +440,11 @@ def test_catalog_update(): assert msg1.locations == [('main.py', 99)] msg2 = cat['blue'] - assert msg2.string == u'blau' + assert msg2.string == 'blau' assert msg2.locations == [('main.py', 100)] msg3 = cat['salad'] - assert msg3.string == (u'Salat', u'Salate') + assert msg3.string == ('Salat', 'Salate') assert msg3.locations == [('util.py', 42)] assert 'head' not in cat diff --git a/tests/messages/test_extract.py b/tests/messages/test_extract.py index 3873191..7a0df8e 100644 --- a/tests/messages/test_extract.py +++ b/tests/messages/test_extract.py @@ -41,14 +41,14 @@ msg10 = dngettext(getDomain(), 'Page', 'Pages', 3) assert messages == [ (1, '_', None, []), (2, 'ungettext', (None, None, None), []), - (3, 'ungettext', (u'Babel', None, None), []), - (4, 'ungettext', (None, u'Babels', None), []), - (5, 'ungettext', (u'bunny', u'bunnies', None), []), - (6, 'ungettext', (None, u'bunnies', None), []), + (3, 'ungettext', ('Babel', None, None), []), + (4, 'ungettext', (None, 'Babels', None), []), + (5, 'ungettext', ('bunny', 'bunnies', None), []), + (6, 'ungettext', (None, 'bunnies', None), []), (7, '_', None, []), - (8, 'gettext', u'Rabbit', []), - (9, 'dgettext', (u'wiki', None), []), - (10, 'dngettext', (None, u'Page', u'Pages', None), []), + (8, 'gettext', 'Rabbit', []), + (9, 'dgettext', ('wiki', None), []), + (10, 'dngettext', (None, 'Page', 'Pages', None), []), ] def test_extract_default_encoding_ascii(self): @@ -60,7 +60,7 @@ msg10 = dngettext(getDomain(), 'Page', 'Pages', 3) assert messages == [(1, '_', 'a', [])] def test_extract_default_encoding_utf8(self): - buf = BytesIO(u'_("☃")'.encode('UTF-8')) + buf = BytesIO('_("☃")'.encode('UTF-8')) messages = list(extract.extract_python( buf, list(extract.DEFAULT_KEYWORDS), [], {}, )) @@ -351,7 +351,7 @@ msg = _('Bonjour à tous') assert messages[0][3] == ['NOTE: hello'] def test_utf8_message_with_magic_comment(self): - buf = BytesIO(u"""# -*- coding: utf-8 -*- + buf = BytesIO("""# -*- coding: utf-8 -*- # NOTE: hello msg = _('Bonjour à tous') """.encode('utf-8')) @@ -360,7 +360,7 @@ msg = _('Bonjour à tous') assert messages[0][3] == ['NOTE: hello'] def test_utf8_message_with_utf8_bom(self): - buf = BytesIO(codecs.BOM_UTF8 + u""" + buf = BytesIO(codecs.BOM_UTF8 + """ # NOTE: hello msg = _('Bonjour à tous') """.encode('utf-8')) @@ -369,7 +369,7 @@ msg = _('Bonjour à tous') assert messages[0][3] == ['NOTE: hello'] def test_utf8_message_with_utf8_bom_and_magic_comment(self): - buf = BytesIO(codecs.BOM_UTF8 + u"""# -*- coding: utf-8 -*- + buf = BytesIO(codecs.BOM_UTF8 + """# -*- coding: utf-8 -*- # NOTE: hello msg = _('Bonjour à tous') """.encode('utf-8')) @@ -378,7 +378,7 @@ msg = _('Bonjour à tous') assert messages[0][3] == ['NOTE: hello'] def test_utf8_bom_with_latin_magic_comment_fails(self): - buf = BytesIO(codecs.BOM_UTF8 + u"""# -*- coding: latin-1 -*- + buf = BytesIO(codecs.BOM_UTF8 + """# -*- coding: latin-1 -*- # NOTE: hello msg = _('Bonjour à tous') """.encode('utf-8')) @@ -386,7 +386,7 @@ msg = _('Bonjour à tous') list(extract.extract_python(buf, ('_',), ['NOTE:'], {})) def test_utf8_raw_strings_match_unicode_strings(self): - buf = BytesIO(codecs.BOM_UTF8 + u""" + buf = BytesIO(codecs.BOM_UTF8 + """ msg = _('Bonjour à tous') msgu = _(u'Bonjour à tous') """.encode('utf-8')) @@ -527,7 +527,7 @@ nbsp = _('\xa0') """) messages = list(extract.extract('python', buf, extract.DEFAULT_KEYWORDS, [], {})) - assert messages[0][1] == u'\xa0' + assert messages[0][1] == '\xa0' def test_f_strings(self): buf = BytesIO(br""" @@ -542,10 +542,10 @@ t4 = _(f'spameggs {t1}') # should not be extracted """) messages = list(extract.extract('python', buf, extract.DEFAULT_KEYWORDS, [], {})) assert len(messages) == 4 - assert messages[0][1] == u'foobar' - assert messages[1][1] == u'spameggsfeast' - assert messages[2][1] == u'spameggskerroshampurilainen' - assert messages[3][1] == u'whoa! a flying shark... hello' + assert messages[0][1] == 'foobar' + assert messages[1][1] == 'spameggsfeast' + assert messages[2][1] == 'spameggskerroshampurilainen' + assert messages[3][1] == 'whoa! a flying shark... hello' def test_f_strings_non_utf8(self): buf = BytesIO(b""" @@ -554,4 +554,4 @@ t2 = _(f'\xe5\xe4\xf6' f'\xc5\xc4\xd6') """) messages = list(extract.extract('python', buf, extract.DEFAULT_KEYWORDS, [], {})) assert len(messages) == 1 - assert messages[0][1] == u'åäöÅÄÖ' + assert messages[0][1] == 'åäöÅÄÖ' diff --git a/tests/messages/test_js_extract.py b/tests/messages/test_js_extract.py index 7d43921..82f5379 100644 --- a/tests/messages/test_js_extract.py +++ b/tests/messages/test_js_extract.py @@ -37,32 +37,32 @@ msg10 = dngettext(domain, 'Page', 'Pages', 3) list(extract.extract('javascript', buf, extract.DEFAULT_KEYWORDS, [], {})) assert messages == [ - (5, (u'bunny', u'bunnies'), [], None), - (8, u'Rabbit', [], None), - (10, (u'Page', u'Pages'), [], None) + (5, ('bunny', 'bunnies'), [], None), + (8, 'Rabbit', [], None), + (10, ('Page', 'Pages'), [], None) ] def test_message_with_line_comment(): - buf = BytesIO(u"""\ + buf = BytesIO("""\ // NOTE: hello msg = _('Bonjour à tous') """.encode('utf-8')) messages = list(extract.extract_javascript(buf, ('_',), ['NOTE:'], {})) - assert messages[0][2] == u'Bonjour à tous' - assert messages[0][3] == [u'NOTE: hello'] + assert messages[0][2] == 'Bonjour à tous' + assert messages[0][3] == ['NOTE: hello'] def test_message_with_multiline_comment(): - buf = BytesIO(u"""\ + buf = BytesIO("""\ /* NOTE: hello and bonjour and servus */ msg = _('Bonjour à tous') """.encode('utf-8')) messages = list(extract.extract_javascript(buf, ('_',), ['NOTE:'], {})) - assert messages[0][2] == u'Bonjour à tous' - assert messages[0][3] == [u'NOTE: hello', 'and bonjour', ' and servus'] + assert messages[0][2] == 'Bonjour à tous' + assert messages[0][3] == ['NOTE: hello', 'and bonjour', ' and servus'] def test_ignore_function_definitions(): @@ -93,11 +93,11 @@ bar() _('no comment here') """) messages = list(extract.extract_javascript(buf, ('_',), ['NOTE:'], {})) - assert messages[0][2] == u'Something' - assert messages[0][3] == [u'NOTE: this will'] - assert messages[1][2] == u'Something else' - assert messages[1][3] == [u'NOTE: this will show up', 'too.'] - assert messages[2][2] == u'no comment here' + assert messages[0][2] == 'Something' + assert messages[0][3] == ['NOTE: this will'] + assert messages[1][2] == 'Something else' + assert messages[1][3] == ['NOTE: this will show up', 'too.'] + assert messages[2][2] == 'no comment here' assert messages[2][3] == [] diff --git a/tests/messages/test_jslexer.py b/tests/messages/test_jslexer.py index bd6322e..3889f0b 100644 --- a/tests/messages/test_jslexer.py +++ b/tests/messages/test_jslexer.py @@ -3,9 +3,9 @@ from babel.messages import jslexer def test_unquote(): assert jslexer.unquote_string('""') == '' - assert jslexer.unquote_string(r'"h\u00ebllo"') == u"hëllo" - assert jslexer.unquote_string(r'"h\xebllo"') == u"hëllo" - assert jslexer.unquote_string(r'"\xebb"') == u"ëb" + assert jslexer.unquote_string(r'"h\u00ebllo"') == "hëllo" + assert jslexer.unquote_string(r'"h\xebllo"') == "hëllo" + assert jslexer.unquote_string(r'"\xebb"') == "ëb" def test_dollar_in_identifier(): diff --git a/tests/messages/test_mofile.py b/tests/messages/test_mofile.py index ff7c2ed..6a702ed 100644 --- a/tests/messages/test_mofile.py +++ b/tests/messages/test_mofile.py @@ -42,12 +42,12 @@ class WriteMoTestCase(unittest.TestCase): # can be applied to all subsequent messages by GNUTranslations # (ensuring all messages are safely converted to unicode) catalog = Catalog(locale='en_US') - catalog.add(u'', '''\ + catalog.add('', '''\ "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n''') - catalog.add(u'foo', 'Voh') - catalog.add((u'There is', u'There are'), (u'Es gibt', u'Es gibt')) - catalog.add(u'Fizz', '') + catalog.add('foo', 'Voh') + catalog.add(('There is', 'There are'), ('Es gibt', 'Es gibt')) + catalog.add('Fizz', '') catalog.add(('Fuzz', 'Fuzzes'), ('', '')) buf = BytesIO() mofile.write_mo(buf, catalog) @@ -67,18 +67,18 @@ class WriteMoTestCase(unittest.TestCase): def test_empty_translation_with_fallback(self): catalog1 = Catalog(locale='fr_FR') - catalog1.add(u'', '''\ + catalog1.add('', '''\ "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n''') - catalog1.add(u'Fuzz', '') + catalog1.add('Fuzz', '') buf1 = BytesIO() mofile.write_mo(buf1, catalog1) buf1.seek(0) catalog2 = Catalog(locale='fr') - catalog2.add(u'', '''\ + catalog2.add('', '''\ "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n''') - catalog2.add(u'Fuzz', 'Flou') + catalog2.add('Fuzz', 'Flou') buf2 = BytesIO() mofile.write_mo(buf2, catalog2) buf2.seek(0) diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py index fb5799b..f668ea0 100644 --- a/tests/messages/test_pofile.py +++ b/tests/messages/test_pofile.py @@ -51,7 +51,7 @@ msgstr "Voh"''') assert catalog.domain == 'mydomain' def test_applies_specified_encoding_during_read(self): - buf = BytesIO(u''' + buf = BytesIO(''' msgid "" msgstr "" "Project-Id-Version: 3.15\\n" @@ -206,7 +206,7 @@ msgstr "Bahr" ''') catalog = pofile.read_po(buf) assert len(catalog.obsolete) == 1 - message = catalog.obsolete[u'foofoo'] + message = catalog.obsolete['foofoo'] assert message.id == 'foofoo' assert message.string == 'VohVooooh' assert message.user_comments == ['This is an obsolete message'] @@ -227,7 +227,7 @@ msgstr "Bahr" ''') catalog = pofile.read_po(buf) assert len(catalog) == 1 - message = catalog[u'bar'] + message = catalog['bar'] assert message.id == 'bar' assert message.string == 'Bahr' assert message.user_comments == ['This message is not obsolete'] @@ -249,7 +249,7 @@ msgstr "Bahr" ''') catalog = pofile.read_po(buf) assert len(catalog) == 1 - message = catalog[u'bar'] + message = catalog['bar'] assert message.id == 'bar' assert message.string == 'Bahr' assert message.user_comments == ['This message is not obsolete'] @@ -298,7 +298,7 @@ msgstr "Bahr" catalog = pofile.read_po(buf) assert len(catalog) == 2 assert len(catalog.obsolete) == 1 - message = catalog.obsolete[u"foo"] + message = catalog.obsolete["foo"] assert message.context == 'other' assert message.string == 'Voh' @@ -486,7 +486,7 @@ msgstr[2] "Vohs [text]" def test_invalid_pofile_with_abort_flag(self): parser = pofile.PoFileParser(None, abort_invalid=True) lineno = 10 - line = u'Algo esta mal' + line = 'Algo esta mal' msg = 'invalid file' with pytest.raises(pofile.PoFileError): parser._invalid_pofile(line, lineno, msg) @@ -496,8 +496,8 @@ class WritePoTestCase(unittest.TestCase): def test_join_locations(self): catalog = Catalog() - catalog.add(u'foo', locations=[('main.py', 1)]) - catalog.add(u'foo', locations=[('utils.py', 3)]) + catalog.add('foo', locations=[('main.py', 1)]) + catalog.add('foo', locations=[('utils.py', 3)]) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True) assert buf.getvalue().strip() == b'''#: main.py:1 utils.py:3 @@ -506,17 +506,17 @@ msgstr ""''' def test_write_po_file_with_specified_charset(self): catalog = Catalog(charset='iso-8859-1') - catalog.add('foo', u'äöü', locations=[('main.py', 1)]) + catalog.add('foo', 'äöü', locations=[('main.py', 1)]) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=False) po_file = buf.getvalue().strip() assert b'"Content-Type: text/plain; charset=iso-8859-1\\n"' in po_file - assert u'msgstr "äöü"'.encode('iso-8859-1') in po_file + assert 'msgstr "äöü"'.encode('iso-8859-1') in po_file def test_duplicate_comments(self): catalog = Catalog() - catalog.add(u'foo', auto_comments=['A comment']) - catalog.add(u'foo', auto_comments=['A comment']) + catalog.add('foo', auto_comments=['A comment']) + catalog.add('foo', auto_comments=['A comment']) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True) assert buf.getvalue().strip() == b'''#. A comment @@ -579,10 +579,10 @@ msgstr ""''' def test_wrap_locations_with_hyphens(self): catalog = Catalog() - catalog.add(u'foo', locations=[ + catalog.add('foo', locations=[ ('doupy/templates/base/navmenu.inc.html.py', 60) ]) - catalog.add(u'foo', locations=[ + catalog.add('foo', locations=[ ('doupy/templates/job-offers/helpers.html', 22) ]) buf = BytesIO() @@ -625,9 +625,9 @@ msgstr "" def test_pot_with_translator_comments(self): catalog = Catalog() - catalog.add(u'foo', locations=[('main.py', 1)], + catalog.add('foo', locations=[('main.py', 1)], auto_comments=['Comment About `foo`']) - catalog.add(u'bar', locations=[('utils.py', 3)], + catalog.add('bar', locations=[('utils.py', 3)], user_comments=['Comment About `bar` with', 'multiple lines.']) buf = BytesIO() @@ -645,8 +645,8 @@ msgstr ""''' def test_po_with_obsolete_message(self): catalog = Catalog() - catalog.add(u'foo', u'Voh', locations=[('main.py', 1)]) - catalog.obsolete['bar'] = Message(u'bar', u'Bahr', + catalog.add('foo', 'Voh', locations=[('main.py', 1)]) + catalog.obsolete['bar'] = Message('bar', 'Bahr', locations=[('utils.py', 3)], user_comments=['User comment']) buf = BytesIO() @@ -661,7 +661,7 @@ msgstr "Voh" def test_po_with_multiline_obsolete_message(self): catalog = Catalog() - catalog.add(u'foo', u'Voh', locations=[('main.py', 1)]) + catalog.add('foo', 'Voh', locations=[('main.py', 1)]) msgid = r"""Here's a message that covers multiple lines, and should still be handled correctly. @@ -689,8 +689,8 @@ msgstr "Voh" def test_po_with_obsolete_message_ignored(self): catalog = Catalog() - catalog.add(u'foo', u'Voh', locations=[('main.py', 1)]) - catalog.obsolete['bar'] = Message(u'bar', u'Bahr', + catalog.add('foo', 'Voh', locations=[('main.py', 1)]) + catalog.obsolete['bar'] = Message('bar', 'Bahr', locations=[('utils.py', 3)], user_comments=['User comment']) buf = BytesIO() @@ -701,8 +701,8 @@ msgstr "Voh"''' def test_po_with_previous_msgid(self): catalog = Catalog() - catalog.add(u'foo', u'Voh', locations=[('main.py', 1)], - previous_id=u'fo') + catalog.add('foo', 'Voh', locations=[('main.py', 1)], + previous_id='fo') buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True, include_previous=True) assert buf.getvalue().strip() == b'''#: main.py:1 @@ -712,8 +712,8 @@ msgstr "Voh"''' def test_po_with_previous_msgid_plural(self): catalog = Catalog() - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), - locations=[('main.py', 1)], previous_id=(u'fo', u'fos')) + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), + locations=[('main.py', 1)], previous_id=('fo', 'fos')) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True, include_previous=True) assert buf.getvalue().strip() == b'''#: main.py:1 @@ -726,10 +726,10 @@ msgstr[1] "Voeh"''' def test_sorted_po(self): catalog = Catalog() - catalog.add(u'bar', locations=[('utils.py', 3)], + catalog.add('bar', locations=[('utils.py', 3)], user_comments=['Comment About `bar` with', 'multiple lines.']) - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), locations=[('main.py', 1)]) buf = BytesIO() pofile.write_po(buf, catalog, sort_output=True) @@ -750,12 +750,12 @@ msgstr[1] "Voeh"''' in value def test_sorted_po_context(self): catalog = Catalog() - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), locations=[('main.py', 1)], context='there') - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), locations=[('main.py', 1)]) - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), locations=[('main.py', 1)], context='here') buf = BytesIO() @@ -785,8 +785,8 @@ msgstr[1] "Voeh"''' in value def test_file_sorted_po(self): catalog = Catalog() - catalog.add(u'bar', locations=[('utils.py', 3)]) - catalog.add((u'foo', u'foos'), (u'Voh', u'Voeh'), locations=[('main.py', 1)]) + catalog.add('bar', locations=[('utils.py', 3)]) + catalog.add(('foo', 'foos'), ('Voh', 'Voeh'), locations=[('main.py', 1)]) buf = BytesIO() pofile.write_po(buf, catalog, sort_by_file=True) value = buf.getvalue().strip() @@ -794,7 +794,7 @@ msgstr[1] "Voeh"''' in value def test_file_with_no_lineno(self): catalog = Catalog() - catalog.add(u'bar', locations=[('utils.py', None)], + catalog.add('bar', locations=[('utils.py', None)], user_comments=['Comment About `bar` with', 'multiple lines.']) buf = BytesIO() @@ -822,8 +822,8 @@ msgstr ""''') def test_include_lineno(self): catalog = Catalog() - catalog.add(u'foo', locations=[('main.py', 1)]) - catalog.add(u'foo', locations=[('utils.py', 3)]) + catalog.add('foo', locations=[('main.py', 1)]) + catalog.add('foo', locations=[('utils.py', 3)]) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True, include_lineno=True) assert buf.getvalue().strip() == b'''#: main.py:1 utils.py:3 @@ -832,9 +832,9 @@ msgstr ""''' def test_no_include_lineno(self): catalog = Catalog() - catalog.add(u'foo', locations=[('main.py', 1)]) - catalog.add(u'foo', locations=[('main.py', 2)]) - catalog.add(u'foo', locations=[('utils.py', 3)]) + catalog.add('foo', locations=[('main.py', 1)]) + catalog.add('foo', locations=[('main.py', 2)]) + catalog.add('foo', locations=[('utils.py', 3)]) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True, include_lineno=False) assert buf.getvalue().strip() == b'''#: main.py utils.py @@ -845,8 +845,8 @@ msgstr ""''' class PofileFunctionsTestCase(unittest.TestCase): def test_unescape(self): - escaped = u'"Say:\\n \\"hello, world!\\"\\n"' - unescaped = u'Say:\n "hello, world!"\n' + escaped = '"Say:\\n \\"hello, world!\\"\\n"' + unescaped = 'Say:\n "hello, world!"\n' assert unescaped != escaped assert unescaped == pofile.unescape(escaped) @@ -858,7 +858,7 @@ class PofileFunctionsTestCase(unittest.TestCase): # handle irregular multi-line msgstr (no "" as first line) # gracefully (#171) msgstr = '"multi-line\\n"\n" translation"' - expected_denormalized = u'multi-line\n translation' + expected_denormalized = 'multi-line\n translation' assert expected_denormalized == pofile.denormalize(msgstr) assert expected_denormalized == pofile.denormalize(f'""\n{msgstr}') |