]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Apply ruff UP025 (unicode literal prefix) fix
authorAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 18:59:35 +0000 (20:59 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 19:20:51 +0000 (21:20 +0200)
22 files changed:
babel/dates.py
babel/messages/catalog.py
babel/messages/frontend.py
babel/messages/jslexer.py
babel/messages/pofile.py
babel/numbers.py
docs/conf.py
pyproject.toml
scripts/import_cldr.py
tests/messages/test_catalog.py
tests/messages/test_extract.py
tests/messages/test_js_extract.py
tests/messages/test_jslexer.py
tests/messages/test_mofile.py
tests/messages/test_pofile.py
tests/test_core.py
tests/test_date_intervals.py
tests/test_dates.py
tests/test_lists.py
tests/test_numbers.py
tests/test_support.py
tests/test_util.py

index 7bfea7111d81f37c2a5d25deca5f733b84d6b191..26766a6959041dfb6c5891cf1657d8d0593859a0 100644 (file)
@@ -49,7 +49,7 @@ if TYPE_CHECKING:
 #  empty set characters ( U+2205 )."
 #  - https://www.unicode.org/reports/tr35/tr35-dates.html#Metazone_Names
 
-NO_INHERITANCE_MARKER = u'\u2205\u2205\u2205'
+NO_INHERITANCE_MARKER = '\u2205\u2205\u2205'
 
 
 if pytz:
@@ -558,11 +558,11 @@ def get_timezone_gmt(
     if return_z and hours == 0 and seconds == 0:
         return 'Z'
     elif seconds == 0 and width == 'iso8601_short':
-        return u'%+03d' % hours
+        return '%+03d' % hours
     elif width == 'short' or width == 'iso8601_short':
-        pattern = u'%+03d%02d'
+        pattern = '%+03d%02d'
     elif width == 'iso8601':
-        pattern = u'%+03d:%02d'
+        pattern = '%+03d:%02d'
     else:
         pattern = locale.zone_formats['gmt'] % '%+03d:%02d'
     return pattern % (hours, seconds // 60)
@@ -1083,10 +1083,10 @@ def format_timedelta(
                     break
             # This really should not happen
             if pattern is None:
-                return u''
+                return ''
             return pattern.replace('{0}', str(value))
 
-    return u''
+    return ''
 
 
 def _format_fallback_interval(
@@ -1849,7 +1849,7 @@ def parse_pattern(pattern: str) -> DateTimePattern:
         else:
             raise NotImplementedError(f"Unknown token type: {tok_type}")
 
-    _pattern_cache[pattern] = pat = DateTimePattern(pattern, u''.join(result))
+    _pattern_cache[pattern] = pat = DateTimePattern(pattern, ''.join(result))
     return pat
 
 
index dbca10f4567601bd5815fbe0c9c49ee8ff18c2a3..85f16b259f959dfb274f13513f02e389f4d01d88 100644 (file)
@@ -80,7 +80,7 @@ class Message:
     def __init__(
         self,
         id: _MessageID,
-        string: _MessageID | None = u'',
+        string: _MessageID | None = '',
         locations: Iterable[tuple[str, int]] = (),
         flags: Iterable[str] = (),
         auto_comments: Iterable[str] = (),
@@ -107,7 +107,7 @@ class Message:
         """
         self.id = id
         if not string and self.pluralizable:
-            string = (u'', u'')
+            string = ('', '')
         self.string = string
         self.locations = list(distinct(locations))
         self.flags = set(flags)
@@ -233,7 +233,7 @@ class TranslationError(Exception):
     translations are encountered."""
 
 
-DEFAULT_HEADER = u"""\
+DEFAULT_HEADER = """\
 # Translations template for PROJECT.
 # Copyright (C) YEAR ORGANIZATION
 # This file is distributed under the same license as the PROJECT project.
@@ -444,7 +444,7 @@ class Catalog:
             value = self._force_text(value, encoding=self.charset)
             if name == 'project-id-version':
                 parts = value.split(' ')
-                self.project = u' '.join(parts[:-1])
+                self.project = ' '.join(parts[:-1])
                 self.version = parts[-1]
             elif name == 'report-msgid-bugs-to':
                 self.msgid_bugs_address = value
@@ -591,7 +591,7 @@ class Catalog:
         flags = set()
         if self.fuzzy:
             flags |= {'fuzzy'}
-        yield Message(u'', '\n'.join(buf), flags=flags)
+        yield Message('', '\n'.join(buf), flags=flags)
         for key in self._messages:
             yield self._messages[key]
 
@@ -831,7 +831,7 @@ class Catalog:
                 if not isinstance(message.string, (list, tuple)):
                     fuzzy = True
                     message.string = tuple(
-                        [message.string] + ([u''] * (len(message.id) - 1))
+                        [message.string] + ([''] * (len(message.id) - 1))
                     )
                 elif len(message.string) != self.num_plurals:
                     fuzzy = True
@@ -841,7 +841,7 @@ class Catalog:
                 message.string = message.string[0]
             message.flags |= oldmsg.flags
             if fuzzy:
-                message.flags |= {u'fuzzy'}
+                message.flags |= {'fuzzy'}
             self[message.id] = message
 
         for message in template:
index 98a1ca89a65950845cbe82f58889a995ef5ee325..de17b1ea59dcea41eebe8b94a129e1661bedf547 100644 (file)
@@ -948,7 +948,7 @@ class CommandLineInterface:
             identifiers = localedata.locale_identifiers()
             longest = max(len(identifier) for identifier in identifiers)
             identifiers.sort()
-            format = u'%%-%ds %%s' % (longest + 1)
+            format = '%%-%ds %%s' % (longest + 1)
             for identifier in identifiers:
                 locale = Locale.parse(identifier)
                 print(format % (identifier, locale.english_name))
index e6d20aec58be9054be1ffd908cbe44c0a49a575d..6eab920750a40c405397a660185a454e32c61ac6 100644 (file)
@@ -154,7 +154,7 @@ def unquote_string(string: str) -> str:
     if pos < len(string):
         add(string[pos:])
 
-    return u''.join(result)
+    return ''.join(result)
 
 
 def tokenize(source: str, jsx: bool = True, dotted: bool = True, template_string: bool = True, lineno: int = 1) -> Generator[Token, None, None]:
index 76d3123e7b70470c59d2be0fbfee0020d1fb3001..a9180a719a30f38eac01d7216c3a447f5da157e8 100644 (file)
@@ -184,7 +184,7 @@ class PoFileParser:
             string = ['' for _ in range(self.catalog.num_plurals)]
             for idx, translation in self.translations:
                 if idx >= self.catalog.num_plurals:
-                    self._invalid_pofile(u"", self.offset, "msg has more translations than num_plurals of catalog")
+                    self._invalid_pofile("", self.offset, "msg has more translations than num_plurals of catalog")
                     continue
                 string[idx] = translation.denormalize()
             string = tuple(string)
@@ -320,8 +320,8 @@ class PoFileParser:
         # No actual messages found, but there was some info in comments, from which
         # we'll construct an empty header message
         if not self.counter and (self.flags or self.user_comments or self.auto_comments):
-            self.messages.append(_NormalizedString(u'""'))
-            self.translations.append([0, _NormalizedString(u'""')])
+            self.messages.append(_NormalizedString('""'))
+            self.translations.append([0, _NormalizedString('""')])
             self._add_message()
 
     def _invalid_pofile(self, line, lineno, msg) -> None:
@@ -462,7 +462,7 @@ def normalize(string: str, prefix: str = '', width: int = 76) -> str:
                                 # separate line
                                 buf.append(chunks.pop())
                             break
-                    lines.append(u''.join(buf))
+                    lines.append(''.join(buf))
             else:
                 lines.append(line)
     else:
@@ -475,7 +475,7 @@ def normalize(string: str, prefix: str = '', width: int = 76) -> str:
     if lines and not lines[-1]:
         del lines[-1]
         lines[-1] += '\n'
-    return u'""\n' + u'\n'.join([(prefix + escape(line)) for line in lines])
+    return '""\n' + '\n'.join([(prefix + escape(line)) for line in lines])
 
 
 def write_po(
@@ -586,7 +586,7 @@ def write_po(
                 for line in comment_header.splitlines():
                     lines += wraptext(line, width=width,
                                       subsequent_indent='# ')
-                comment_header = u'\n'.join(lines)
+                comment_header = '\n'.join(lines)
             _write(f"{comment_header}\n")
 
         for comment in message.user_comments:
index 6ecd7dc1110eb180b4db0ef1b1ea5860e1814d52..399b70b5c50285b747292acda090739cf749bc54 100644 (file)
@@ -324,7 +324,7 @@ def get_decimal_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
 
     :param locale: the `Locale` object or locale identifier
     """
-    return Locale.parse(locale).number_symbols.get('decimal', u'.')
+    return Locale.parse(locale).number_symbols.get('decimal', '.')
 
 
 def get_plus_sign_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
@@ -335,7 +335,7 @@ def get_plus_sign_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
 
     :param locale: the `Locale` object or locale identifier
     """
-    return Locale.parse(locale).number_symbols.get('plusSign', u'+')
+    return Locale.parse(locale).number_symbols.get('plusSign', '+')
 
 
 def get_minus_sign_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
@@ -346,7 +346,7 @@ def get_minus_sign_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
 
     :param locale: the `Locale` object or locale identifier
     """
-    return Locale.parse(locale).number_symbols.get('minusSign', u'-')
+    return Locale.parse(locale).number_symbols.get('minusSign', '-')
 
 
 def get_exponential_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
@@ -357,7 +357,7 @@ def get_exponential_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
 
     :param locale: the `Locale` object or locale identifier
     """
-    return Locale.parse(locale).number_symbols.get('exponential', u'E')
+    return Locale.parse(locale).number_symbols.get('exponential', 'E')
 
 
 def get_group_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
@@ -368,11 +368,11 @@ def get_group_symbol(locale: Locale | str | None = LC_NUMERIC) -> str:
 
     :param locale: the `Locale` object or locale identifier
     """
-    return Locale.parse(locale).number_symbols.get('group', u',')
+    return Locale.parse(locale).number_symbols.get('group', ',')
 
 
 def format_number(number: float | decimal.Decimal | str, locale: Locale | str | None = LC_NUMERIC) -> str:
-    u"""Return the given number formatted for a specific locale.
+    """Return the given number formatted for a specific locale.
 
     >>> format_number(1099, locale='en_US')  # doctest: +SKIP
     u'1,099'
@@ -418,7 +418,7 @@ def format_decimal(
     decimal_quantization: bool = True,
     group_separator: bool = True,
 ) -> str:
-    u"""Return the given decimal number formatted for a specific locale.
+    """Return the given decimal number formatted for a specific locale.
 
     >>> format_decimal(1.2345, locale='en_US')
     u'1.234'
@@ -473,7 +473,7 @@ def format_compact_decimal(
     locale: Locale | str | None = LC_NUMERIC,
     fraction_digits: int = 0,
 ) -> str:
-    u"""Return the given decimal number formatted for a specific locale in compact form.
+    """Return the given decimal number formatted for a specific locale in compact form.
 
     >>> format_compact_decimal(12345, format_type="short", locale='en_US')
     u'12K'
@@ -555,7 +555,7 @@ def format_currency(
     decimal_quantization: bool = True,
     group_separator: bool = True,
 ) -> str:
-    u"""Return formatted currency value.
+    """Return formatted currency value.
 
     >>> format_currency(1099.98, 'USD', locale='en_US')
     u'$1,099.98'
@@ -711,7 +711,7 @@ def format_compact_currency(
     locale: Locale | str | None = LC_NUMERIC,
     fraction_digits: int = 0
 ) -> str:
-    u"""Format a number as a currency value in compact form.
+    """Format a number as a currency value in compact form.
 
     >>> format_compact_currency(12345, 'USD', locale='en_US')
     u'$12K'
@@ -916,7 +916,7 @@ def parse_decimal(string: str, locale: Locale | str | None = LC_NUMERIC, strict:
     decimal_symbol = get_decimal_symbol(locale)
 
     if not strict and (
-        group_symbol == u'\xa0' and  # if the grouping symbol is U+00A0 NO-BREAK SPACE,
+        group_symbol == '\xa0' and  # if the grouping symbol is U+00A0 NO-BREAK SPACE,
         group_symbol not in string and  # and the string to be parsed does not contain it,
         ' ' in string  # but it does contain a space instead,
     ):
@@ -1095,7 +1095,7 @@ class NumberPattern:
         scale = 0
         if '%' in ''.join(self.prefix + self.suffix):
             scale = 2
-        elif u'‰' in ''.join(self.prefix + self.suffix):
+        elif '‰' in ''.join(self.prefix + self.suffix):
             scale = 3
         return scale
 
@@ -1222,11 +1222,11 @@ class NumberPattern:
             number if self.number_pattern != '' else '',
             self.suffix[is_negative]])
 
-        if u'¤' in retval:
-            retval = retval.replace(u'¤¤¤',
+        if '¤' in retval:
+            retval = retval.replace('¤¤¤',
                                     get_currency_name(currency, value, locale))
-            retval = retval.replace(u'¤¤', currency.upper())
-            retval = retval.replace(u'¤', get_currency_symbol(currency, locale))
+            retval = retval.replace('¤¤', currency.upper())
+            retval = retval.replace('¤', get_currency_symbol(currency, locale))
 
         # remove single quotes around text, except for doubled single quotes
         # which are replaced with a single quote
index 84bbd7ed2e43d93cbd8a5befd38d16bbe5a94d10..5118f72f6d98bb2f36d4019a72bf18dfc146a83e 100644 (file)
@@ -43,8 +43,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'Babel'
-copyright = u'2022, The Babel Team'
+project = 'Babel'
+copyright = '2022, The Babel Team'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -194,8 +194,8 @@ latex_elements = {
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'Babel.tex', u'Babel Documentation',
-   u'The Babel Team', 'manual'),
+  ('index', 'Babel.tex', 'Babel Documentation',
+   'The Babel Team', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -224,7 +224,7 @@ latex_logo = '_static/logo.png'
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'babel', u'Babel Documentation', [u'The Babel Team'], 1),
+    ('index', 'babel', 'Babel Documentation', ['The Babel Team'], 1),
 ]
 
 # If true, show URL addresses after external links.
@@ -237,8 +237,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index_', 'Babel', u'Babel Documentation',
-   u'The Babel Team', 'Babel', 'One line description of project.',
+  ('index_', 'Babel', 'Babel Documentation',
+   'The Babel Team', 'Babel', 'One line description of project.',
    'Miscellaneous'),
 ]
 
index a7915af10d5b22173bf07f8a0257ca57ef4b1dc3..10c1db8b307f938a552fc67a288898ef1a8458d2 100644 (file)
@@ -7,12 +7,14 @@ select = [
     "F",
     "I",
     "SIM300",
+    "UP025",
 ]
 ignore = [
     "C901",  # Complexity
     "E501",  # Line length
     "E731",  # Do not assign a lambda expression (we use them on purpose)
     "E741",  # Ambiguous variable name
+    "UP012",  # "utf-8" is on purpose
 ]
 extend-exclude = [
     "tests/messages/data",
index 0dc47382f08b56860f9dc911a4b62f76bb34c8cf..b5034073eb27d0a9476fd87baa8d385a4356dadc 100755 (executable)
@@ -43,7 +43,7 @@ def _text(elem):
     for child in elem:
         buf.append(_text(child))
     buf.append(elem.tail or '')
-    return u''.join(filter(None, buf)).strip()
+    return ''.join(filter(None, buf)).strip()
 
 
 NAME_RE = re.compile(r"^\w+$")
index eb1e308f2dc9f1f0ce6f13a7072d65ffe5ade0cd..29cfc0d65a176c6b5c9633003809cbf60e458289 100644 (file)
@@ -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
index 3873191138b4d1e33758ca63f7625fad8b131e45..7a0df8ecbb0e2a46fb17bc750586c45988281313 100644 (file)
@@ -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] == 'åäöÅÄÖ'
index 7d4392150228d793f9471031cd2fbcc2a1bfb744..82f5379eae644e4ac708967997df12394a2fd3d0 100644 (file)
@@ -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] == []
 
 
index bd6322e9e9e39dcfcbb3b16b0ffbbacdcdf4ba6a..3889f0b3a344a0b5aed8a584d45ccd29dd99f344 100644 (file)
@@ -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():
index ff7c2ed0b00c9ad9d94d855da40ceb4f67bc2eba..6a702edb442ba9f275fc6b17c3c62fb070844e04 100644 (file)
@@ -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)
index fb5799b169bc950dcf9f2522a17780cfa0de963e..f668ea033303954ffe84cac7a22153ee7d5ec564 100644 (file)
@@ -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}')
index cc234550ebfa35db2d2850d24d8d70b8a48c55b5..c0e0b3d9447429b9a9fdaad416ea4e7c2d31ecdc 100644 (file)
@@ -18,8 +18,8 @@ from babel.core import Locale, default_locale
 
 def test_locale_provides_access_to_cldr_locale_data():
     locale = Locale('en', 'US')
-    assert locale.display_name == u'English (United States)'
-    assert locale.number_symbols['decimal'] == u'.'
+    assert locale.display_name == 'English (United States)'
+    assert locale.number_symbols['decimal'] == '.'
 
 
 def test_locale_repr():
@@ -169,9 +169,9 @@ class TestLocaleClass:
 
     def test_currency_formats_property(self):
         assert (Locale('en', 'US').currency_formats['standard'].pattern ==
-                u'\xa4#,##0.00')
+                '\xa4#,##0.00')
         assert (Locale('en', 'US').currency_formats['accounting'].pattern ==
-                u'\xa4#,##0.00;(\xa4#,##0.00)')
+                '\xa4#,##0.00;(\xa4#,##0.00)')
 
     def test_percent_formats_property(self):
         assert Locale('en', 'US').percent_formats[None].pattern == '#,##0%'
@@ -199,7 +199,7 @@ class TestLocaleClass:
         time_zones = Locale('en', 'US').time_zones
         assert (time_zones['Europe/London']['long']['daylight'] ==
                 'British Summer Time')
-        assert time_zones['America/St_Johns']['city'] == u'St. John\u2019s'
+        assert time_zones['America/St_Johns']['city'] == 'St. John\u2019s'
 
     def test_meta_zones_property(self):
         meta_zones = Locale('en', 'US').meta_zones
@@ -208,7 +208,7 @@ class TestLocaleClass:
 
     def test_zone_formats_property(self):
         assert Locale('en', 'US').zone_formats['fallback'] == '%(1)s (%(0)s)'
-        assert Locale('pt', 'BR').zone_formats['region'] == u'Hor\xe1rio %s'
+        assert Locale('pt', 'BR').zone_formats['region'] == 'Hor\xe1rio %s'
 
     def test_first_week_day_property(self):
         assert Locale('de', 'DE').first_week_day == 0
@@ -232,12 +232,12 @@ class TestLocaleClass:
         assert Locale('fr', 'FR').time_formats['long'].pattern == 'HH:mm:ss z'
 
     def test_datetime_formats_property(self):
-        assert Locale('en').datetime_formats['full'] == u"{1} 'at' {0}"
-        assert Locale('th').datetime_formats['medium'] == u'{1} {0}'
+        assert Locale('en').datetime_formats['full'] == "{1} 'at' {0}"
+        assert Locale('th').datetime_formats['medium'] == '{1} {0}'
 
     def test_datetime_skeleton_property(self):
-        assert Locale('en').datetime_skeletons['Md'].pattern == u"M/d"
-        assert Locale('th').datetime_skeletons['Md'].pattern == u'd/M'
+        assert Locale('en').datetime_skeletons['Md'].pattern == "M/d"
+        assert Locale('th').datetime_skeletons['Md'].pattern == 'd/M'
 
     def test_plural_form_property(self):
         assert Locale('en').plural_form(1) == 'one'
index 8e84a9eb60d2e73f34c4f0f59e42d6f50b935ccd..556585488dacabcdb259bdb6c176c206289b046d 100644 (file)
@@ -46,8 +46,8 @@ def test_format_interval_12_hour():
 def test_format_interval_invalid_skeleton():
     t1 = TEST_DATE
     t2 = TEST_DATE + datetime.timedelta(days=1)
-    assert dates.format_interval(t1, t2, "mumumu", fuzzy=False, locale="fi") == u"8.1.2016\u20139.1.2016"
-    assert dates.format_interval(t1, t2, fuzzy=False, locale="fi") == u"8.1.2016\u20139.1.2016"
+    assert dates.format_interval(t1, t2, "mumumu", fuzzy=False, locale="fi") == "8.1.2016\u20139.1.2016"
+    assert dates.format_interval(t1, t2, fuzzy=False, locale="fi") == "8.1.2016\u20139.1.2016"
 
 
 def test_issue_825():
index b4abaf9341298035bf369e38d76637f3bc7b2a35..fd85a1b97908e003a9dc5038c2313e6aa65b37df 100644 (file)
@@ -213,7 +213,7 @@ class DateTimeFormatTestCase:
     def test_timezone_walltime_long(self, timezone_getter):
         tz = timezone_getter('Europe/Paris')
         t = time(15, 30, tzinfo=tz)
-        assert dates.DateTimeFormat(t, locale='fr_FR')['vvvv'] == u'heure d’Europe centrale'
+        assert dates.DateTimeFormat(t, locale='fr_FR')['vvvv'] == 'heure d’Europe centrale'
 
     def test_hour_formatting(self):
         l = 'en_US'
@@ -252,75 +252,75 @@ class FormatDatetimeTestCase:
         d = datetime(2012, 4, 1, 15, 30, 29, tzinfo=UTC)
         epoch = float(calendar.timegm(d.timetuple()))
         formatted_string = dates.format_datetime(epoch, format='long', locale='en_US')
-        assert formatted_string == u'April 1, 2012 at 3:30:29 PM UTC'
+        assert formatted_string == 'April 1, 2012 at 3:30:29 PM UTC'
 
     def test_timezone_formats_los_angeles(self, timezone_getter):
         tz = timezone_getter('America/Los_Angeles')
         dt = _localize(tz, datetime(2016, 1, 13, 7, 8, 35))
-        assert dates.format_datetime(dt, 'z', locale='en') == u'PST'
-        assert dates.format_datetime(dt, 'zz', locale='en') == u'PST'
-        assert dates.format_datetime(dt, 'zzz', locale='en') == u'PST'
-        assert dates.format_datetime(dt, 'zzzz', locale='en') == u'Pacific Standard Time'
-        assert dates.format_datetime(dt, 'Z', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'ZZ', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'ZZZ', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == u'GMT-08:00'
-        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == u'-08:00'
-        assert dates.format_datetime(dt, 'OOOO', locale='en') == u'GMT-08:00'
-        assert dates.format_datetime(dt, 'VV', locale='en') == u'America/Los_Angeles'
-        assert dates.format_datetime(dt, 'VVV', locale='en') == u'Los Angeles'
-        assert dates.format_datetime(dt, 'X', locale='en') == u'-08'
-        assert dates.format_datetime(dt, 'XX', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'XXX', locale='en') == u'-08:00'
-        assert dates.format_datetime(dt, 'XXXX', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'XXXXX', locale='en') == u'-08:00'
-        assert dates.format_datetime(dt, 'x', locale='en') == u'-08'
-        assert dates.format_datetime(dt, 'xx', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'xxx', locale='en') == u'-08:00'
-        assert dates.format_datetime(dt, 'xxxx', locale='en') == u'-0800'
-        assert dates.format_datetime(dt, 'xxxxx', locale='en') == u'-08:00'
+        assert dates.format_datetime(dt, 'z', locale='en') == 'PST'
+        assert dates.format_datetime(dt, 'zz', locale='en') == 'PST'
+        assert dates.format_datetime(dt, 'zzz', locale='en') == 'PST'
+        assert dates.format_datetime(dt, 'zzzz', locale='en') == 'Pacific Standard Time'
+        assert dates.format_datetime(dt, 'Z', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'ZZ', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'ZZZ', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == 'GMT-08:00'
+        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == '-08:00'
+        assert dates.format_datetime(dt, 'OOOO', locale='en') == 'GMT-08:00'
+        assert dates.format_datetime(dt, 'VV', locale='en') == 'America/Los_Angeles'
+        assert dates.format_datetime(dt, 'VVV', locale='en') == 'Los Angeles'
+        assert dates.format_datetime(dt, 'X', locale='en') == '-08'
+        assert dates.format_datetime(dt, 'XX', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'XXX', locale='en') == '-08:00'
+        assert dates.format_datetime(dt, 'XXXX', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'XXXXX', locale='en') == '-08:00'
+        assert dates.format_datetime(dt, 'x', locale='en') == '-08'
+        assert dates.format_datetime(dt, 'xx', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'xxx', locale='en') == '-08:00'
+        assert dates.format_datetime(dt, 'xxxx', locale='en') == '-0800'
+        assert dates.format_datetime(dt, 'xxxxx', locale='en') == '-08:00'
 
     def test_timezone_formats_utc(self, timezone_getter):
         tz = timezone_getter('UTC')
         dt = _localize(tz, datetime(2016, 1, 13, 7, 8, 35))
-        assert dates.format_datetime(dt, 'Z', locale='en') == u'+0000'
-        assert dates.format_datetime(dt, 'ZZ', locale='en') == u'+0000'
-        assert dates.format_datetime(dt, 'ZZZ', locale='en') == u'+0000'
-        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == u'GMT+00:00'
-        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'OOOO', locale='en') == u'GMT+00:00'
-        assert dates.format_datetime(dt, 'VV', locale='en') == u'Etc/UTC'
-        assert dates.format_datetime(dt, 'VVV', locale='en') == u'UTC'
-        assert dates.format_datetime(dt, 'X', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'XX', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'XXX', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'XXXX', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'XXXXX', locale='en') == u'Z'
-        assert dates.format_datetime(dt, 'x', locale='en') == u'+00'
-        assert dates.format_datetime(dt, 'xx', locale='en') == u'+0000'
-        assert dates.format_datetime(dt, 'xxx', locale='en') == u'+00:00'
-        assert dates.format_datetime(dt, 'xxxx', locale='en') == u'+0000'
-        assert dates.format_datetime(dt, 'xxxxx', locale='en') == u'+00:00'
+        assert dates.format_datetime(dt, 'Z', locale='en') == '+0000'
+        assert dates.format_datetime(dt, 'ZZ', locale='en') == '+0000'
+        assert dates.format_datetime(dt, 'ZZZ', locale='en') == '+0000'
+        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == 'GMT+00:00'
+        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'OOOO', locale='en') == 'GMT+00:00'
+        assert dates.format_datetime(dt, 'VV', locale='en') == 'Etc/UTC'
+        assert dates.format_datetime(dt, 'VVV', locale='en') == 'UTC'
+        assert dates.format_datetime(dt, 'X', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'XX', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'XXX', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'XXXX', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'XXXXX', locale='en') == 'Z'
+        assert dates.format_datetime(dt, 'x', locale='en') == '+00'
+        assert dates.format_datetime(dt, 'xx', locale='en') == '+0000'
+        assert dates.format_datetime(dt, 'xxx', locale='en') == '+00:00'
+        assert dates.format_datetime(dt, 'xxxx', locale='en') == '+0000'
+        assert dates.format_datetime(dt, 'xxxxx', locale='en') == '+00:00'
 
     def test_timezone_formats_kolkata(self, timezone_getter):
         tz = timezone_getter('Asia/Kolkata')
         dt = _localize(tz, datetime(2016, 1, 13, 7, 8, 35))
-        assert dates.format_datetime(dt, 'zzzz', locale='en') == u'India Standard Time'
-        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == u'GMT+05:30'
-        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == u'+05:30'
-        assert dates.format_datetime(dt, 'OOOO', locale='en') == u'GMT+05:30'
-        assert dates.format_datetime(dt, 'VV', locale='en') == u'Asia/Calcutta'
-        assert dates.format_datetime(dt, 'VVV', locale='en') == u'Kolkata'
-        assert dates.format_datetime(dt, 'X', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'XX', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'XXX', locale='en') == u'+05:30'
-        assert dates.format_datetime(dt, 'XXXX', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'XXXXX', locale='en') == u'+05:30'
-        assert dates.format_datetime(dt, 'x', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'xx', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'xxx', locale='en') == u'+05:30'
-        assert dates.format_datetime(dt, 'xxxx', locale='en') == u'+0530'
-        assert dates.format_datetime(dt, 'xxxxx', locale='en') == u'+05:30'
+        assert dates.format_datetime(dt, 'zzzz', locale='en') == 'India Standard Time'
+        assert dates.format_datetime(dt, 'ZZZZ', locale='en') == 'GMT+05:30'
+        assert dates.format_datetime(dt, 'ZZZZZ', locale='en') == '+05:30'
+        assert dates.format_datetime(dt, 'OOOO', locale='en') == 'GMT+05:30'
+        assert dates.format_datetime(dt, 'VV', locale='en') == 'Asia/Calcutta'
+        assert dates.format_datetime(dt, 'VVV', locale='en') == 'Kolkata'
+        assert dates.format_datetime(dt, 'X', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'XX', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'XXX', locale='en') == '+05:30'
+        assert dates.format_datetime(dt, 'XXXX', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'XXXXX', locale='en') == '+05:30'
+        assert dates.format_datetime(dt, 'x', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'xx', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'xxx', locale='en') == '+05:30'
+        assert dates.format_datetime(dt, 'xxxx', locale='en') == '+0530'
+        assert dates.format_datetime(dt, 'xxxxx', locale='en') == '+05:30'
 
 
 class FormatTimeTestCase:
@@ -337,7 +337,7 @@ class FormatTimeTestCase:
         tz = timezone_getter('UTC')
         d = _localize(tz, datetime(2012, 4, 1, 15, 30, 29))
         epoch = float(calendar.timegm(d.timetuple()))
-        assert dates.format_time(epoch, format='long', locale='en_US') == u'3:30:29 PM UTC'
+        assert dates.format_time(epoch, format='long', locale='en_US') == '3:30:29 PM UTC'
 
     def test_with_date_fields_in_pattern(self):
         with pytest.raises(AttributeError):
@@ -398,122 +398,122 @@ class TimeZoneAdjustTestCase:
 
 
 def test_get_period_names():
-    assert dates.get_period_names(locale='en_US')['am'] == u'AM'
+    assert dates.get_period_names(locale='en_US')['am'] == 'AM'
 
 
 def test_get_day_names():
-    assert dates.get_day_names('wide', locale='en_US')[1] == u'Tuesday'
-    assert dates.get_day_names('short', locale='en_US')[1] == u'Tu'
-    assert dates.get_day_names('abbreviated', locale='es')[1] == u'mar'
+    assert dates.get_day_names('wide', locale='en_US')[1] == 'Tuesday'
+    assert dates.get_day_names('short', locale='en_US')[1] == 'Tu'
+    assert dates.get_day_names('abbreviated', locale='es')[1] == 'mar'
     de = dates.get_day_names('narrow', context='stand-alone', locale='de_DE')
-    assert de[1] == u'D'
+    assert de[1] == 'D'
 
 
 def test_get_month_names():
-    assert dates.get_month_names('wide', locale='en_US')[1] == u'January'
-    assert dates.get_month_names('abbreviated', locale='es')[1] == u'ene'
+    assert dates.get_month_names('wide', locale='en_US')[1] == 'January'
+    assert dates.get_month_names('abbreviated', locale='es')[1] == 'ene'
     de = dates.get_month_names('narrow', context='stand-alone', locale='de_DE')
-    assert de[1] == u'J'
+    assert de[1] == 'J'
 
 
 def test_get_quarter_names():
-    assert dates.get_quarter_names('wide', locale='en_US')[1] == u'1st quarter'
-    assert dates.get_quarter_names('abbreviated', locale='de_DE')[1] == u'Q1'
-    assert dates.get_quarter_names('narrow', locale='de_DE')[1] == u'1'
+    assert dates.get_quarter_names('wide', locale='en_US')[1] == '1st quarter'
+    assert dates.get_quarter_names('abbreviated', locale='de_DE')[1] == 'Q1'
+    assert dates.get_quarter_names('narrow', locale='de_DE')[1] == '1'
 
 
 def test_get_era_names():
-    assert dates.get_era_names('wide', locale='en_US')[1] == u'Anno Domini'
-    assert dates.get_era_names('abbreviated', locale='de_DE')[1] == u'n. Chr.'
+    assert dates.get_era_names('wide', locale='en_US')[1] == 'Anno Domini'
+    assert dates.get_era_names('abbreviated', locale='de_DE')[1] == 'n. Chr.'
 
 
 def test_get_date_format():
     us = dates.get_date_format(locale='en_US')
-    assert us.pattern == u'MMM d, y'
+    assert us.pattern == 'MMM d, y'
     de = dates.get_date_format('full', locale='de_DE')
-    assert de.pattern == u'EEEE, d. MMMM y'
+    assert de.pattern == 'EEEE, d. MMMM y'
 
 
 def test_get_datetime_format():
-    assert dates.get_datetime_format(locale='en_US') == u'{1}, {0}'
+    assert dates.get_datetime_format(locale='en_US') == '{1}, {0}'
 
 
 def test_get_time_format():
-    assert dates.get_time_format(locale='en_US').pattern == u'h:mm:ss a'
+    assert dates.get_time_format(locale='en_US').pattern == 'h:mm:ss a'
     assert (dates.get_time_format('full', locale='de_DE').pattern ==
-            u'HH:mm:ss zzzz')
+            'HH:mm:ss zzzz')
 
 
 def test_get_timezone_gmt(timezone_getter):
     dt = datetime(2007, 4, 1, 15, 30)
-    assert dates.get_timezone_gmt(dt, locale='en') == u'GMT+00:00'
+    assert dates.get_timezone_gmt(dt, locale='en') == 'GMT+00:00'
     assert dates.get_timezone_gmt(dt, locale='en', return_z=True) == 'Z'
-    assert dates.get_timezone_gmt(dt, locale='en', width='iso8601_short') == u'+00'
+    assert dates.get_timezone_gmt(dt, locale='en', width='iso8601_short') == '+00'
     tz = timezone_getter('America/Los_Angeles')
     dt = _localize(tz, datetime(2007, 4, 1, 15, 30))
-    assert dates.get_timezone_gmt(dt, locale='en') == u'GMT-07:00'
-    assert dates.get_timezone_gmt(dt, 'short', locale='en') == u'-0700'
-    assert dates.get_timezone_gmt(dt, locale='en', width='iso8601_short') == u'-07'
-    assert dates.get_timezone_gmt(dt, 'long', locale='fr_FR') == u'UTC-07:00'
+    assert dates.get_timezone_gmt(dt, locale='en') == 'GMT-07:00'
+    assert dates.get_timezone_gmt(dt, 'short', locale='en') == '-0700'
+    assert dates.get_timezone_gmt(dt, locale='en', width='iso8601_short') == '-07'
+    assert dates.get_timezone_gmt(dt, 'long', locale='fr_FR') == 'UTC-07:00'
 
 
 def test_get_timezone_location(timezone_getter):
     tz = timezone_getter('America/St_Johns')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            u"Kanada (St. John\u2019s) Zeit")
+            "Kanada (St. John\u2019s) Zeit")
     assert (dates.get_timezone_location(tz, locale='en') ==
-            u'Canada (St. John’s) Time')
+            'Canada (St. John’s) Time')
     assert (dates.get_timezone_location(tz, locale='en', return_city=True) ==
-            u'St. John’s')
+            'St. John’s')
 
     tz = timezone_getter('America/Mexico_City')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            u'Mexiko (Mexiko-Stadt) Zeit')
+            'Mexiko (Mexiko-Stadt) Zeit')
 
     tz = timezone_getter('Europe/Berlin')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            u'Deutschland (Berlin) Zeit')
+            'Deutschland (Berlin) Zeit')
 
 
 @pytest.mark.parametrize(
     "tzname, params, expected",
     [
-        ("America/Los_Angeles", {"locale": "en_US"}, u"Pacific Time"),
-        ("America/Los_Angeles", {"width": "short", "locale": "en_US"}, u"PT"),
-        ("Europe/Berlin", {"locale": "de_DE"}, u"Mitteleurop\xe4ische Zeit"),
-        ("Europe/Berlin", {"locale": "pt_BR"}, u"Hor\xe1rio da Europa Central"),
-        ("America/St_Johns", {"locale": "de_DE"}, u"Neufundland-Zeit"),
+        ("America/Los_Angeles", {"locale": "en_US"}, "Pacific Time"),
+        ("America/Los_Angeles", {"width": "short", "locale": "en_US"}, "PT"),
+        ("Europe/Berlin", {"locale": "de_DE"}, "Mitteleurop\xe4ische Zeit"),
+        ("Europe/Berlin", {"locale": "pt_BR"}, "Hor\xe1rio da Europa Central"),
+        ("America/St_Johns", {"locale": "de_DE"}, "Neufundland-Zeit"),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "short", "zone_variant": "generic"},
-            u"PT",
+            "PT",
         ),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "short", "zone_variant": "standard"},
-            u"PST",
+            "PST",
         ),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "short", "zone_variant": "daylight"},
-            u"PDT",
+            "PDT",
         ),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "long", "zone_variant": "generic"},
-            u"Pacific Time",
+            "Pacific Time",
         ),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "long", "zone_variant": "standard"},
-            u"Pacific Standard Time",
+            "Pacific Standard Time",
         ),
         (
             "America/Los_Angeles",
             {"locale": "en", "width": "long", "zone_variant": "daylight"},
-            u"Pacific Daylight Time",
+            "Pacific Daylight Time",
         ),
-        ("Europe/Berlin", {"locale": "en_US"}, u"Central European Time"),
+        ("Europe/Berlin", {"locale": "en_US"}, "Central European Time"),
     ],
 )
 def test_get_timezone_name_tzinfo(timezone_getter, tzname, params, expected):
@@ -525,13 +525,13 @@ def test_get_timezone_name_tzinfo(timezone_getter, tzname, params, expected):
 @pytest.mark.parametrize(
     "tzname, params, expected",
     [
-        ("America/Los_Angeles", {"locale": "en_US"}, u"Pacific Standard Time"),
+        ("America/Los_Angeles", {"locale": "en_US"}, "Pacific Standard Time"),
         (
             "America/Los_Angeles",
             {"locale": "en_US", "return_zone": True},
-            u"America/Los_Angeles",
+            "America/Los_Angeles",
         ),
-        ("America/Los_Angeles", {"width": "short", "locale": "en_US"}, u"PST"),
+        ("America/Los_Angeles", {"width": "short", "locale": "en_US"}, "PST"),
     ],
 )
 def test_get_timezone_name_time_pytz(timezone_getter, tzname, params, expected):
@@ -554,40 +554,40 @@ def test_get_timezone_name_misc(timezone_getter):
 
 def test_format_date():
     d = date(2007, 4, 1)
-    assert dates.format_date(d, locale='en_US') == u'Apr 1, 2007'
+    assert dates.format_date(d, locale='en_US') == 'Apr 1, 2007'
     assert (dates.format_date(d, format='full', locale='de_DE') ==
-            u'Sonntag, 1. April 2007')
+            'Sonntag, 1. April 2007')
     assert (dates.format_date(d, "EEE, MMM d, ''yy", locale='en') ==
-            u"Sun, Apr 1, '07")
+            "Sun, Apr 1, '07")
 
 
 def test_format_datetime(timezone_getter):
     dt = datetime(2007, 4, 1, 15, 30)
     assert (dates.format_datetime(dt, locale='en_US') ==
-            u'Apr 1, 2007, 3:30:00 PM')
+            'Apr 1, 2007, 3:30:00 PM')
 
     full = dates.format_datetime(
         dt, 'full',
         tzinfo=timezone_getter('Europe/Paris'),
         locale='fr_FR'
     )
-    assert full == (u'dimanche 1 avril 2007 à 17:30:00 heure '
+    assert full == ('dimanche 1 avril 2007 à 17:30:00 heure '
                     u'd\u2019\xe9t\xe9 d\u2019Europe centrale')
     custom = dates.format_datetime(
         dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
         tzinfo=timezone_getter('US/Eastern'),
         locale='en'
     )
-    assert custom == u'2007.04.01 AD at 11:30:00 EDT'
+    assert custom == '2007.04.01 AD at 11:30:00 EDT'
 
 
 def test_format_time(timezone_getter):
     t = time(15, 30)
-    assert dates.format_time(t, locale='en_US') == u'3:30:00 PM'
-    assert dates.format_time(t, format='short', locale='de_DE') == u'15:30'
+    assert dates.format_time(t, locale='en_US') == '3:30:00 PM'
+    assert dates.format_time(t, format='short', locale='de_DE') == '15:30'
 
     assert (dates.format_time(t, "hh 'o''clock' a", locale='en') ==
-            u"03 o'clock PM")
+            "03 o'clock PM")
 
     paris = timezone_getter('Europe/Paris')
     eastern = timezone_getter('US/Eastern')
@@ -597,41 +597,41 @@ def test_format_time(timezone_getter):
     assert fr == '15:30:00 heure d’été d’Europe centrale'
 
     custom = dates.format_time(t, "hh 'o''clock' a, zzzz", tzinfo=eastern, locale='en')
-    assert custom == u"09 o'clock AM, Eastern Daylight Time"
+    assert custom == "09 o'clock AM, Eastern Daylight Time"
 
     t = time(15, 30)
     paris = dates.format_time(t, format='full', tzinfo=paris, locale='fr_FR')
     assert paris == '15:30:00 heure normale d’Europe centrale'
 
     us_east = dates.format_time(t, format='full', tzinfo=eastern, locale='en_US')
-    assert us_east == u'3:30:00 PM Eastern Standard Time'
+    assert us_east == '3:30:00 PM Eastern Standard Time'
 
 
 def test_format_skeleton(timezone_getter):
     dt = datetime(2007, 4, 1, 15, 30)
-    assert (dates.format_skeleton('yMEd', dt, locale='en_US') == u'Sun, 4/1/2007')
-    assert (dates.format_skeleton('yMEd', dt, locale='th') == u'อา. 1/4/2007')
+    assert (dates.format_skeleton('yMEd', dt, locale='en_US') == 'Sun, 4/1/2007')
+    assert (dates.format_skeleton('yMEd', dt, locale='th') == 'อา. 1/4/2007')
 
-    assert (dates.format_skeleton('EHm', dt, locale='en') == u'Sun 15:30')
-    assert (dates.format_skeleton('EHm', dt, tzinfo=timezone_getter('Asia/Bangkok'), locale='th') == u'อา. 22:30 น.')
+    assert (dates.format_skeleton('EHm', dt, locale='en') == 'Sun 15:30')
+    assert (dates.format_skeleton('EHm', dt, tzinfo=timezone_getter('Asia/Bangkok'), locale='th') == 'อา. 22:30 น.')
 
 
 def test_format_timedelta():
     assert (dates.format_timedelta(timedelta(weeks=12), locale='en_US')
-            == u'3 months')
+            == '3 months')
     assert (dates.format_timedelta(timedelta(seconds=1), locale='es')
-            == u'1 segundo')
+            == '1 segundo')
 
     assert (dates.format_timedelta(timedelta(hours=3), granularity='day',
                                    locale='en_US')
-            == u'1 day')
+            == '1 day')
 
     assert (dates.format_timedelta(timedelta(hours=23), threshold=0.9,
                                    locale='en_US')
-            == u'1 day')
+            == '1 day')
     assert (dates.format_timedelta(timedelta(hours=23), threshold=1.1,
                                    locale='en_US')
-            == u'23 hours')
+            == '23 hours')
 
 
 def test_parse_date():
@@ -679,24 +679,24 @@ def test_datetime_format_get_week_number():
 
 
 def test_parse_pattern():
-    assert dates.parse_pattern("MMMMd").format == u'%(MMMM)s%(d)s'
+    assert dates.parse_pattern("MMMMd").format == '%(MMMM)s%(d)s'
     assert (dates.parse_pattern("MMM d, yyyy").format ==
-            u'%(MMM)s %(d)s, %(yyyy)s')
+            '%(MMM)s %(d)s, %(yyyy)s')
     assert (dates.parse_pattern("H:mm' Uhr 'z").format ==
-            u'%(H)s:%(mm)s Uhr %(z)s')
-    assert dates.parse_pattern("hh' o''clock'").format == u"%(hh)s o'clock"
+            '%(H)s:%(mm)s Uhr %(z)s')
+    assert dates.parse_pattern("hh' o''clock'").format == "%(hh)s o'clock"
 
 
 def test_lithuanian_long_format():
     assert (
         dates.format_date(date(2015, 12, 10), locale='lt_LT', format='long') ==
-        u'2015 m. gruodžio 10 d.'
+        '2015 m. gruodžio 10 d.'
     )
 
 
 def test_zh_TW_format():
     # Refs GitHub issue #378
-    assert dates.format_time(datetime(2016, 4, 8, 12, 34, 56), locale='zh_TW') == u'中午12:34:56'
+    assert dates.format_time(datetime(2016, 4, 8, 12, 34, 56), locale='zh_TW') == '中午12:34:56'
 
 
 def test_format_current_moment():
index e51f18b236abf20a4469eb52048a4e3f4b0e64eb..ca9c6ab41a30e8cd69da49ff3488d5fcf0830b59 100644 (file)
@@ -6,11 +6,11 @@ from babel import lists
 def test_format_list():
     for list, locale, expected in [
         ([], 'en', ''),
-        ([u'string'], 'en', u'string'),
-        (['string1', 'string2'], 'en', u'string1 and string2'),
-        (['string1', 'string2', 'string3'], 'en', u'string1, string2, and string3'),
-        (['string1', 'string2', 'string3'], 'zh', u'string1、string2和string3'),
-        (['string1', 'string2', 'string3', 'string4'], 'ne', u'string1,string2, string3 र string4'),
+        (['string'], 'en', 'string'),
+        (['string1', 'string2'], 'en', 'string1 and string2'),
+        (['string1', 'string2', 'string3'], 'en', 'string1, string2, and string3'),
+        (['string1', 'string2', 'string3'], 'zh', 'string1、string2和string3'),
+        (['string1', 'string2', 'string3', 'string4'], 'ne', 'string1,string2, string3 र string4'),
     ]:
         assert lists.format_list(list, locale=locale) == expected
 
index ca33c1e2b479a597e2c8e26a6af9a7b428ebb046..a6f79f01c46f29491a9d9062f5d298f3ca00b9d6 100644 (file)
@@ -38,7 +38,7 @@ class FormatDecimalTestCase(unittest.TestCase):
         # regression test for #183, fraction digits were not correctly cut
         # if the input was a float value and the value had more than 7
         # significant digits
-        assert numbers.format_decimal(12345678.051, '#,##0.00', locale='en_US') == u'12,345,678.05'
+        assert numbers.format_decimal(12345678.051, '#,##0.00', locale='en_US') == '12,345,678.05'
 
     def test_subpatterns(self):
         assert numbers.format_decimal((- 12345), '#,##0.##;-#', locale='en_US') == '-12,345'
@@ -115,57 +115,57 @@ class FormatDecimalTestCase(unittest.TestCase):
         assert numbers.format_decimal(29567.12, locale='en_US', group_separator=False) == '29567.12'
         assert numbers.format_decimal(29567.12, locale='fr_CA', group_separator=False) == '29567,12'
         assert numbers.format_decimal(29567.12, locale='pt_BR', group_separator=False) == '29567,12'
-        assert numbers.format_currency(1099.98, 'USD', locale='en_US', group_separator=False) == u'$1099.98'
-        assert numbers.format_currency(101299.98, 'EUR', locale='fr_CA', group_separator=False) == u'101299,98\xa0€'
+        assert numbers.format_currency(1099.98, 'USD', locale='en_US', group_separator=False) == '$1099.98'
+        assert numbers.format_currency(101299.98, 'EUR', locale='fr_CA', group_separator=False) == '101299,98\xa0€'
         assert numbers.format_currency(101299.98, 'EUR', locale='en_US', group_separator=False, format_type='name') == '101299.98 euros'
-        assert numbers.format_percent(251234.1234, locale='sv_SE', group_separator=False) == u'25123412\xa0%'
+        assert numbers.format_percent(251234.1234, locale='sv_SE', group_separator=False) == '25123412\xa0%'
 
-        assert numbers.format_decimal(29567.12, locale='en_US', group_separator=True) == u'29,567.12'
-        assert numbers.format_decimal(29567.12, locale='fr_CA', group_separator=True) == u'29\xa0567,12'
-        assert numbers.format_decimal(29567.12, locale='pt_BR', group_separator=True) == u'29.567,12'
-        assert numbers.format_currency(1099.98, 'USD', locale='en_US', group_separator=True) == u'$1,099.98'
-        assert numbers.format_currency(101299.98, 'EUR', locale='fr_CA', group_separator=True) == u'101\xa0299,98\xa0€'
-        assert numbers.format_currency(101299.98, 'EUR', locale='en_US', group_separator=True, format_type='name') == u'101,299.98 euros'
-        assert numbers.format_percent(251234.1234, locale='sv_SE', group_separator=True) == u'25\xa0123\xa0412\xa0%'
+        assert numbers.format_decimal(29567.12, locale='en_US', group_separator=True) == '29,567.12'
+        assert numbers.format_decimal(29567.12, locale='fr_CA', group_separator=True) == '29\xa0567,12'
+        assert numbers.format_decimal(29567.12, locale='pt_BR', group_separator=True) == '29.567,12'
+        assert numbers.format_currency(1099.98, 'USD', locale='en_US', group_separator=True) == '$1,099.98'
+        assert numbers.format_currency(101299.98, 'EUR', locale='fr_CA', group_separator=True) == '101\xa0299,98\xa0€'
+        assert numbers.format_currency(101299.98, 'EUR', locale='en_US', group_separator=True, format_type='name') == '101,299.98 euros'
+        assert numbers.format_percent(251234.1234, locale='sv_SE', group_separator=True) == '25\xa0123\xa0412\xa0%'
 
     def test_compact(self):
-        assert numbers.format_compact_decimal(1, locale='en_US', format_type="short") == u'1'
-        assert numbers.format_compact_decimal(999, locale='en_US', format_type="short") == u'999'
-        assert numbers.format_compact_decimal(1000, locale='en_US', format_type="short") == u'1K'
-        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="short") == u'9K'
-        assert numbers.format_compact_decimal(9123, locale='en_US', format_type="short", fraction_digits=2) == u'9.12K'
-        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="short") == u'10K'
-        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="short", fraction_digits=2) == u'10K'
-        assert numbers.format_compact_decimal(1000000, locale='en_US', format_type="short") == u'1M'
-        assert numbers.format_compact_decimal(9000999, locale='en_US', format_type="short") == u'9M'
-        assert numbers.format_compact_decimal(9000900099, locale='en_US', format_type="short", fraction_digits=5) == u'9.0009B'
-        assert numbers.format_compact_decimal(1, locale='en_US', format_type="long") == u'1'
-        assert numbers.format_compact_decimal(999, locale='en_US', format_type="long") == u'999'
-        assert numbers.format_compact_decimal(1000, locale='en_US', format_type="long") == u'1 thousand'
-        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="long") == u'9 thousand'
-        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="long", fraction_digits=2) == u'9 thousand'
-        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="long") == u'10 thousand'
-        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="long", fraction_digits=2) == u'10 thousand'
-        assert numbers.format_compact_decimal(1000000, locale='en_US', format_type="long") == u'1 million'
-        assert numbers.format_compact_decimal(9999999, locale='en_US', format_type="long") == u'10 million'
-        assert numbers.format_compact_decimal(9999999999, locale='en_US', format_type="long", fraction_digits=5) == u'10 billion'
-        assert numbers.format_compact_decimal(1, locale='ja_JP', format_type="short") == u'1'
-        assert numbers.format_compact_decimal(999, locale='ja_JP', format_type="short") == u'999'
-        assert numbers.format_compact_decimal(1000, locale='ja_JP', format_type="short") == u'1000'
-        assert numbers.format_compact_decimal(9123, locale='ja_JP', format_type="short") == u'9123'
-        assert numbers.format_compact_decimal(10000, locale='ja_JP', format_type="short") == u'1万'
-        assert numbers.format_compact_decimal(1234567, locale='ja_JP', format_type="long") == u'123万'
-        assert numbers.format_compact_decimal(-1, locale='en_US', format_type="short") == u'-1'
-        assert numbers.format_compact_decimal(-1234, locale='en_US', format_type="short", fraction_digits=2) == u'-1.23K'
-        assert numbers.format_compact_decimal(-123456789, format_type='short', locale='en_US') == u'-123M'
-        assert numbers.format_compact_decimal(-123456789, format_type='long', locale='en_US') == u'-123 million'
-        assert numbers.format_compact_decimal(2345678, locale='mk', format_type='long') == u'2 милиони'
-        assert numbers.format_compact_decimal(21000000, locale='mk', format_type='long') == u'21 милион'
-        assert numbers.format_compact_decimal(21345, locale="gv", format_type="short") == u'21K'
-        assert numbers.format_compact_decimal(1000, locale='it', format_type='long') == u'mille'
-        assert numbers.format_compact_decimal(1234, locale='it', format_type='long') == u'1 mila'
-        assert numbers.format_compact_decimal(1000, locale='fr', format_type='long') == u'mille'
-        assert numbers.format_compact_decimal(1234, locale='fr', format_type='long') == u'1 millier'
+        assert numbers.format_compact_decimal(1, locale='en_US', format_type="short") == '1'
+        assert numbers.format_compact_decimal(999, locale='en_US', format_type="short") == '999'
+        assert numbers.format_compact_decimal(1000, locale='en_US', format_type="short") == '1K'
+        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="short") == '9K'
+        assert numbers.format_compact_decimal(9123, locale='en_US', format_type="short", fraction_digits=2) == '9.12K'
+        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="short") == '10K'
+        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="short", fraction_digits=2) == '10K'
+        assert numbers.format_compact_decimal(1000000, locale='en_US', format_type="short") == '1M'
+        assert numbers.format_compact_decimal(9000999, locale='en_US', format_type="short") == '9M'
+        assert numbers.format_compact_decimal(9000900099, locale='en_US', format_type="short", fraction_digits=5) == '9.0009B'
+        assert numbers.format_compact_decimal(1, locale='en_US', format_type="long") == '1'
+        assert numbers.format_compact_decimal(999, locale='en_US', format_type="long") == '999'
+        assert numbers.format_compact_decimal(1000, locale='en_US', format_type="long") == '1 thousand'
+        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="long") == '9 thousand'
+        assert numbers.format_compact_decimal(9000, locale='en_US', format_type="long", fraction_digits=2) == '9 thousand'
+        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="long") == '10 thousand'
+        assert numbers.format_compact_decimal(10000, locale='en_US', format_type="long", fraction_digits=2) == '10 thousand'
+        assert numbers.format_compact_decimal(1000000, locale='en_US', format_type="long") == '1 million'
+        assert numbers.format_compact_decimal(9999999, locale='en_US', format_type="long") == '10 million'
+        assert numbers.format_compact_decimal(9999999999, locale='en_US', format_type="long", fraction_digits=5) == '10 billion'
+        assert numbers.format_compact_decimal(1, locale='ja_JP', format_type="short") == '1'
+        assert numbers.format_compact_decimal(999, locale='ja_JP', format_type="short") == '999'
+        assert numbers.format_compact_decimal(1000, locale='ja_JP', format_type="short") == '1000'
+        assert numbers.format_compact_decimal(9123, locale='ja_JP', format_type="short") == '9123'
+        assert numbers.format_compact_decimal(10000, locale='ja_JP', format_type="short") == '1万'
+        assert numbers.format_compact_decimal(1234567, locale='ja_JP', format_type="long") == '123万'
+        assert numbers.format_compact_decimal(-1, locale='en_US', format_type="short") == '-1'
+        assert numbers.format_compact_decimal(-1234, locale='en_US', format_type="short", fraction_digits=2) == '-1.23K'
+        assert numbers.format_compact_decimal(-123456789, format_type='short', locale='en_US') == '-123M'
+        assert numbers.format_compact_decimal(-123456789, format_type='long', locale='en_US') == '-123 million'
+        assert numbers.format_compact_decimal(2345678, locale='mk', format_type='long') == '2 милиони'
+        assert numbers.format_compact_decimal(21000000, locale='mk', format_type='long') == '21 милион'
+        assert numbers.format_compact_decimal(21345, locale="gv", format_type="short") == '21K'
+        assert numbers.format_compact_decimal(1000, locale='it', format_type='long') == 'mille'
+        assert numbers.format_compact_decimal(1234, locale='it', format_type='long') == '1 mila'
+        assert numbers.format_compact_decimal(1000, locale='fr', format_type='long') == 'mille'
+        assert numbers.format_compact_decimal(1234, locale='fr', format_type='long') == '1 millier'
 
 class NumberParsingTestCase(unittest.TestCase):
 
@@ -255,12 +255,12 @@ def test_normalize_currency():
 
 
 def test_get_currency_name():
-    assert numbers.get_currency_name('USD', locale='en_US') == u'US Dollar'
-    assert numbers.get_currency_name('USD', count=2, locale='en_US') == u'US dollars'
+    assert numbers.get_currency_name('USD', locale='en_US') == 'US Dollar'
+    assert numbers.get_currency_name('USD', count=2, locale='en_US') == 'US dollars'
 
 
 def test_get_currency_symbol():
-    assert numbers.get_currency_symbol('USD', 'en_US') == u'$'
+    assert numbers.get_currency_symbol('USD', 'en_US') == '$'
 
 
 def test_get_currency_precision():
@@ -301,24 +301,24 @@ def test_get_territory_currencies():
 
 
 def test_get_decimal_symbol():
-    assert numbers.get_decimal_symbol('en_US') == u'.'
+    assert numbers.get_decimal_symbol('en_US') == '.'
 
 
 def test_get_plus_sign_symbol():
-    assert numbers.get_plus_sign_symbol('en_US') == u'+'
+    assert numbers.get_plus_sign_symbol('en_US') == '+'
 
 
 def test_get_minus_sign_symbol():
-    assert numbers.get_minus_sign_symbol('en_US') == u'-'
-    assert numbers.get_minus_sign_symbol('nl_NL') == u'-'
+    assert numbers.get_minus_sign_symbol('en_US') == '-'
+    assert numbers.get_minus_sign_symbol('nl_NL') == '-'
 
 
 def test_get_exponential_symbol():
-    assert numbers.get_exponential_symbol('en_US') == u'E'
+    assert numbers.get_exponential_symbol('en_US') == 'E'
 
 
 def test_get_group_symbol():
-    assert numbers.get_group_symbol('en_US') == u','
+    assert numbers.get_group_symbol('en_US') == ','
 
 
 def test_decimal_precision():
@@ -328,18 +328,18 @@ def test_decimal_precision():
 
 
 def test_format_decimal():
-    assert numbers.format_decimal(1099, locale='en_US') == u'1,099'
-    assert numbers.format_decimal(1099, locale='de_DE') == u'1.099'
-    assert numbers.format_decimal(1.2345, locale='en_US') == u'1.234'
-    assert numbers.format_decimal(1.2346, locale='en_US') == u'1.235'
-    assert numbers.format_decimal(-1.2346, locale='en_US') == u'-1.235'
-    assert numbers.format_decimal(1.2345, locale='sv_SE') == u'1,234'
-    assert numbers.format_decimal(1.2345, locale='de') == u'1,234'
-    assert numbers.format_decimal(12345.5, locale='en_US') == u'12,345.5'
-    assert numbers.format_decimal(0001.2345000, locale='en_US') == u'1.234'
-    assert numbers.format_decimal(-0001.2346000, locale='en_US') == u'-1.235'
-    assert numbers.format_decimal(0000000.5, locale='en_US') == u'0.5'
-    assert numbers.format_decimal(000, locale='en_US') == u'0'
+    assert numbers.format_decimal(1099, locale='en_US') == '1,099'
+    assert numbers.format_decimal(1099, locale='de_DE') == '1.099'
+    assert numbers.format_decimal(1.2345, locale='en_US') == '1.234'
+    assert numbers.format_decimal(1.2346, locale='en_US') == '1.235'
+    assert numbers.format_decimal(-1.2346, locale='en_US') == '-1.235'
+    assert numbers.format_decimal(1.2345, locale='sv_SE') == '1,234'
+    assert numbers.format_decimal(1.2345, locale='de') == '1,234'
+    assert numbers.format_decimal(12345.5, locale='en_US') == '12,345.5'
+    assert numbers.format_decimal(0001.2345000, locale='en_US') == '1.234'
+    assert numbers.format_decimal(-0001.2346000, locale='en_US') == '-1.235'
+    assert numbers.format_decimal(0000000.5, locale='en_US') == '0.5'
+    assert numbers.format_decimal(000, locale='en_US') == '0'
 
 
 @pytest.mark.parametrize('input_value, expected_value', [
@@ -379,43 +379,43 @@ def test_format_decimal_quantization():
 
 def test_format_currency():
     assert (numbers.format_currency(1099.98, 'USD', locale='en_US')
-            == u'$1,099.98')
+            == '$1,099.98')
     assert (numbers.format_currency(0, 'USD', locale='en_US')
-            == u'$0.00')
+            == '$0.00')
     assert (numbers.format_currency(1099.98, 'USD', locale='es_CO')
-            == u'US$\xa01.099,98')
+            == 'US$\xa01.099,98')
     assert (numbers.format_currency(1099.98, 'EUR', locale='de_DE')
-            == u'1.099,98\xa0\u20ac')
-    assert (numbers.format_currency(1099.98, 'EUR', u'\xa4\xa4 #,##0.00',
+            == '1.099,98\xa0\u20ac')
+    assert (numbers.format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00',
                                     locale='en_US')
-            == u'EUR 1,099.98')
+            == 'EUR 1,099.98')
     assert (numbers.format_currency(1099.98, 'EUR', locale='nl_NL')
             != numbers.format_currency(-1099.98, 'EUR', locale='nl_NL'))
     assert (numbers.format_currency(1099.98, 'USD', format=None,
                                     locale='en_US')
-            == u'$1,099.98')
+            == '$1,099.98')
     assert (numbers.format_currency(1, 'USD', locale='es_AR')
-            == u'US$\xa01,00')          # one
+            == 'US$\xa01,00')          # one
     assert (numbers.format_currency(1000000, 'USD', locale='es_AR')
-            == u'US$\xa01.000.000,00')  # many
+            == 'US$\xa01.000.000,00')  # many
     assert (numbers.format_currency(0, 'USD', locale='es_AR')
-            == u'US$\xa00,00')          # other
+            == 'US$\xa00,00')          # other
 
 
 def test_format_currency_format_type():
     assert (numbers.format_currency(1099.98, 'USD', locale='en_US',
                                     format_type="standard")
-            == u'$1,099.98')
+            == '$1,099.98')
     assert (numbers.format_currency(0, 'USD', locale='en_US',
                                     format_type="standard")
-            == u'$0.00')
+            == '$0.00')
 
     assert (numbers.format_currency(1099.98, 'USD', locale='en_US',
                                     format_type="accounting")
-            == u'$1,099.98')
+            == '$1,099.98')
     assert (numbers.format_currency(0, 'USD', locale='en_US',
                                     format_type="accounting")
-            == u'$0.00')
+            == '$0.00')
 
     with pytest.raises(numbers.UnknownCurrencyFormatError) as excinfo:
         numbers.format_currency(1099.98, 'USD', locale='en_US',
@@ -423,27 +423,27 @@ def test_format_currency_format_type():
     assert excinfo.value.args[0] == "'unknown' is not a known currency format type"
 
     assert (numbers.format_currency(1099.98, 'JPY', locale='en_US')
-            == u'\xa51,100')
-    assert (numbers.format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES')
-            == u'1.099,98')
+            == '\xa51,100')
+    assert (numbers.format_currency(1099.98, 'COP', '#,##0.00', locale='es_ES')
+            == '1.099,98')
     assert (numbers.format_currency(1099.98, 'JPY', locale='en_US',
                                     currency_digits=False)
-            == u'\xa51,099.98')
-    assert (numbers.format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES',
+            == '\xa51,099.98')
+    assert (numbers.format_currency(1099.98, 'COP', '#,##0.00', locale='es_ES',
                                     currency_digits=False)
-            == u'1.099,98')
+            == '1.099,98')
 
 
 def test_format_compact_currency():
-    assert numbers.format_compact_currency(1, 'USD', locale='en_US', format_type="short") == u'$1'
-    assert numbers.format_compact_currency(999, 'USD', locale='en_US', format_type="short") == u'$999'
-    assert numbers.format_compact_currency(123456789, 'USD', locale='en_US', format_type="short") == u'$123M'
-    assert numbers.format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2, format_type="short") == u'$123.46M'
-    assert numbers.format_compact_currency(-123456789, 'USD', locale='en_US', fraction_digits=2, format_type="short") == u'-$123.46M'
-    assert numbers.format_compact_currency(1, 'JPY', locale='ja_JP', format_type="short") == u'¥1'
-    assert numbers.format_compact_currency(1234, 'JPY', locale='ja_JP', format_type="short") == u'¥1234'
-    assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short") == u'¥12万'
-    assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short", fraction_digits=2) == u'¥12.35万'
+    assert numbers.format_compact_currency(1, 'USD', locale='en_US', format_type="short") == '$1'
+    assert numbers.format_compact_currency(999, 'USD', locale='en_US', format_type="short") == '$999'
+    assert numbers.format_compact_currency(123456789, 'USD', locale='en_US', format_type="short") == '$123M'
+    assert numbers.format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2, format_type="short") == '$123.46M'
+    assert numbers.format_compact_currency(-123456789, 'USD', locale='en_US', fraction_digits=2, format_type="short") == '-$123.46M'
+    assert numbers.format_compact_currency(1, 'JPY', locale='ja_JP', format_type="short") == '¥1'
+    assert numbers.format_compact_currency(1234, 'JPY', locale='ja_JP', format_type="short") == '¥1234'
+    assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short") == '¥12万'
+    assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short", fraction_digits=2) == '¥12.35万'
     assert numbers.format_compact_currency(123, 'EUR', locale='yav', format_type="short") == '123\xa0€'
     assert numbers.format_compact_currency(12345, 'EUR', locale='yav', format_type="short") == '12K\xa0€'
     assert numbers.format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1) == '123,5\xa0Mio.\xa0€'
@@ -492,30 +492,30 @@ def test_format_currency_quantization():
 
 def test_format_currency_long_display_name():
     assert (numbers.format_currency(1099.98, 'USD', locale='en_US', format_type='name')
-            == u'1,099.98 US dollars')
+            == '1,099.98 US dollars')
     assert (numbers.format_currency(1.00, 'USD', locale='en_US', format_type='name')
-            == u'1.00 US dollar')
+            == '1.00 US dollar')
     assert (numbers.format_currency(1.00, 'EUR', locale='en_US', format_type='name')
-            == u'1.00 euro')
+            == '1.00 euro')
     assert (numbers.format_currency(2, 'EUR', locale='en_US', format_type='name')
-            == u'2.00 euros')
+            == '2.00 euros')
     # This tests that '{1} {0}' unitPatterns are found:
     assert (numbers.format_currency(1, 'USD', locale='sw', format_type='name')
-            == u'dola ya Marekani 1.00')
+            == 'dola ya Marekani 1.00')
     # This tests unicode chars:
     assert (numbers.format_currency(1099.98, 'USD', locale='es_GT', format_type='name')
-            == u'dólares estadounidenses 1,099.98')
+            == 'dólares estadounidenses 1,099.98')
     # Test for completely unknown currency, should fallback to currency code
     assert (numbers.format_currency(1099.98, 'XAB', locale='en_US', format_type='name')
-            == u'1,099.98 XAB')
+            == '1,099.98 XAB')
 
     # Test for finding different unit patterns depending on count
     assert (numbers.format_currency(1, 'USD', locale='ro', format_type='name')
-            == u'1,00 dolar american')
+            == '1,00 dolar american')
     assert (numbers.format_currency(2, 'USD', locale='ro', format_type='name')
-            == u'2,00 dolari americani')
+            == '2,00 dolari americani')
     assert (numbers.format_currency(100, 'USD', locale='ro', format_type='name')
-            == u'100,00 de dolari americani')
+            == '100,00 de dolari americani')
 
 
 def test_format_currency_long_display_name_all():
@@ -537,15 +537,15 @@ def test_format_currency_long_display_name_custom_format():
 
 
 def test_format_percent():
-    assert numbers.format_percent(0.34, locale='en_US') == u'34%'
-    assert numbers.format_percent(0, locale='en_US') == u'0%'
-    assert numbers.format_percent(0.34, u'##0%', locale='en_US') == u'34%'
-    assert numbers.format_percent(34, u'##0', locale='en_US') == u'34'
-    assert numbers.format_percent(25.1234, locale='en_US') == u'2,512%'
+    assert numbers.format_percent(0.34, locale='en_US') == '34%'
+    assert numbers.format_percent(0, locale='en_US') == '0%'
+    assert numbers.format_percent(0.34, '##0%', locale='en_US') == '34%'
+    assert numbers.format_percent(34, '##0', locale='en_US') == '34'
+    assert numbers.format_percent(25.1234, locale='en_US') == '2,512%'
     assert (numbers.format_percent(25.1234, locale='sv_SE')
-            == u'2\xa0512\xa0%')
-    assert (numbers.format_percent(25.1234, u'#,##0\u2030', locale='en_US')
-            == u'25,123\u2030')
+            == '2\xa0512\xa0%')
+    assert (numbers.format_percent(25.1234, '#,##0\u2030', locale='en_US')
+            == '25,123\u2030')
 
 
 @pytest.mark.parametrize('input_value, expected_value', [
@@ -583,25 +583,25 @@ def test_format_percent_quantization():
 
 
 def test_format_scientific():
-    assert numbers.format_scientific(10000, locale='en_US') == u'1E4'
-    assert numbers.format_scientific(4234567, u'#.#E0', locale='en_US') == u'4.2E6'
-    assert numbers.format_scientific(4234567, u'0E0000', locale='en_US') == u'4.234567E0006'
-    assert numbers.format_scientific(4234567, u'##0E00', locale='en_US') == u'4.234567E06'
-    assert numbers.format_scientific(4234567, u'##00E00', locale='en_US') == u'42.34567E05'
-    assert numbers.format_scientific(4234567, u'0,000E00', locale='en_US') == u'4,234.567E03'
-    assert numbers.format_scientific(4234567, u'##0.#####E00', locale='en_US') == u'4.23457E06'
-    assert numbers.format_scientific(4234567, u'##0.##E00', locale='en_US') == u'4.23E06'
-    assert numbers.format_scientific(42, u'00000.000000E0000', locale='en_US') == u'42000.000000E-0003'
+    assert numbers.format_scientific(10000, locale='en_US') == '1E4'
+    assert numbers.format_scientific(4234567, '#.#E0', locale='en_US') == '4.2E6'
+    assert numbers.format_scientific(4234567, '0E0000', locale='en_US') == '4.234567E0006'
+    assert numbers.format_scientific(4234567, '##0E00', locale='en_US') == '4.234567E06'
+    assert numbers.format_scientific(4234567, '##00E00', locale='en_US') == '42.34567E05'
+    assert numbers.format_scientific(4234567, '0,000E00', locale='en_US') == '4,234.567E03'
+    assert numbers.format_scientific(4234567, '##0.#####E00', locale='en_US') == '4.23457E06'
+    assert numbers.format_scientific(4234567, '##0.##E00', locale='en_US') == '4.23E06'
+    assert numbers.format_scientific(42, '00000.000000E0000', locale='en_US') == '42000.000000E-0003'
 
 
 def test_default_scientific_format():
     """ Check the scientific format method auto-correct the rendering pattern
     in case of a missing fractional part.
     """
-    assert numbers.format_scientific(12345, locale='en_US') == u'1.2345E4'
-    assert numbers.format_scientific(12345.678, locale='en_US') == u'1.2345678E4'
-    assert numbers.format_scientific(12345, u'#E0', locale='en_US') == u'1.2345E4'
-    assert numbers.format_scientific(12345.678, u'#E0', locale='en_US') == u'1.2345678E4'
+    assert numbers.format_scientific(12345, locale='en_US') == '1.2345E4'
+    assert numbers.format_scientific(12345.678, locale='en_US') == '1.2345678E4'
+    assert numbers.format_scientific(12345, '#E0', locale='en_US') == '1.2345E4'
+    assert numbers.format_scientific(12345.678, '#E0', locale='en_US') == '1.2345678E4'
 
 
 @pytest.mark.parametrize('input_value, expected_value', [
@@ -667,18 +667,18 @@ def test_parse_grouping():
 def test_parse_pattern():
 
     # Original pattern is preserved
-    np = numbers.parse_pattern(u'¤#,##0.00')
-    assert np.pattern == u'¤#,##0.00'
+    np = numbers.parse_pattern('¤#,##0.00')
+    assert np.pattern == '¤#,##0.00'
 
-    np = numbers.parse_pattern(u'¤#,##0.00;(¤#,##0.00)')
-    assert np.pattern == u'¤#,##0.00;(¤#,##0.00)'
+    np = numbers.parse_pattern('¤#,##0.00;(¤#,##0.00)')
+    assert np.pattern == '¤#,##0.00;(¤#,##0.00)'
 
     # Given a NumberPattern object, we don't return a new instance.
     # However, we don't cache NumberPattern objects, so calling
     # parse_pattern with the same format string will create new
     # instances
-    np1 = numbers.parse_pattern(u'¤ #,##0.00')
-    np2 = numbers.parse_pattern(u'¤ #,##0.00')
+    np1 = numbers.parse_pattern('¤ #,##0.00')
+    np2 = numbers.parse_pattern('¤ #,##0.00')
     assert np1 is not np2
     assert np1 is numbers.parse_pattern(np1)
 
@@ -686,19 +686,19 @@ def test_parse_pattern():
 def test_parse_pattern_negative():
 
     # No negative format specified
-    np = numbers.parse_pattern(u'¤#,##0.00')
-    assert np.prefix == (u'¤', u'-¤')
-    assert np.suffix == (u'', u'')
+    np = numbers.parse_pattern('¤#,##0.00')
+    assert np.prefix == ('¤', '-¤')
+    assert np.suffix == ('', '')
 
     # Negative format is specified
-    np = numbers.parse_pattern(u'¤#,##0.00;(¤#,##0.00)')
-    assert np.prefix == (u'¤', u'(¤')
-    assert np.suffix == (u'', u')')
+    np = numbers.parse_pattern('¤#,##0.00;(¤#,##0.00)')
+    assert np.prefix == ('¤', '(¤')
+    assert np.suffix == ('', ')')
 
     # Negative sign is a suffix
-    np = numbers.parse_pattern(u'¤ #,##0.00;¤ #,##0.00-')
-    assert np.prefix == (u'¤ ', u'¤ ')
-    assert np.suffix == (u'', u'-')
+    np = numbers.parse_pattern('¤ #,##0.00;¤ #,##0.00-')
+    assert np.prefix == ('¤ ', '¤ ')
+    assert np.suffix == ('', '-')
 
 
 def test_numberpattern_repr():
@@ -706,7 +706,7 @@ def test_numberpattern_repr():
 
     # This implementation looks a bit funny, but that's cause strings are
     # repr'd differently in Python 2 vs 3 and this test runs under both.
-    format = u'¤#,##0.00;(¤#,##0.00)'
+    format = '¤#,##0.00;(¤#,##0.00)'
     np = numbers.parse_pattern(format)
     assert repr(format) in repr(np)
 
index fe10402647c806f372ad684e5cfa3287b7ae2f35..36bdcf665b5edc3608b1c78dae174e239654011d 100644 (file)
@@ -71,8 +71,8 @@ class TranslationsTestCase(unittest.TestCase):
                                                                      'foo'))
 
     def test_upgettext(self):
-        self.assertEqualTypeToo(u'Voh', self.translations.ugettext('foo'))
-        self.assertEqualTypeToo(u'VohCTX', self.translations.upgettext('foo',
+        self.assertEqualTypeToo('Voh', self.translations.ugettext('foo'))
+        self.assertEqualTypeToo('VohCTX', self.translations.upgettext('foo',
                                                                        'foo'))
 
     @pytest.mark.skipif(SKIP_LGETTEXT, reason="lgettext is deprecated")
@@ -94,14 +94,14 @@ class TranslationsTestCase(unittest.TestCase):
                                                             'foos1', 2))
 
     def test_unpgettext(self):
-        self.assertEqualTypeToo(u'Voh1',
+        self.assertEqualTypeToo('Voh1',
                                 self.translations.ungettext('foo1', 'foos1', 1))
-        self.assertEqualTypeToo(u'Vohs1',
+        self.assertEqualTypeToo('Vohs1',
                                 self.translations.ungettext('foo1', 'foos1', 2))
-        self.assertEqualTypeToo(u'VohCTX1',
+        self.assertEqualTypeToo('VohCTX1',
                                 self.translations.unpgettext('foo', 'foo1',
                                                              'foos1', 1))
-        self.assertEqualTypeToo(u'VohsCTX1',
+        self.assertEqualTypeToo('VohsCTX1',
                                 self.translations.unpgettext('foo', 'foo1',
                                                              'foos1', 2))
 
@@ -126,9 +126,9 @@ class TranslationsTestCase(unittest.TestCase):
 
     def test_dupgettext(self):
         self.assertEqualTypeToo(
-            u'VohD', self.translations.dugettext('messages1', 'foo'))
+            'VohD', self.translations.dugettext('messages1', 'foo'))
         self.assertEqualTypeToo(
-            u'VohCTXD', self.translations.dupgettext('messages1', 'foo', 'foo'))
+            'VohCTXD', self.translations.dupgettext('messages1', 'foo', 'foo'))
 
     @pytest.mark.skipif(SKIP_LGETTEXT, reason="lgettext is deprecated")
     def test_ldpgettext(self):
@@ -151,14 +151,14 @@ class TranslationsTestCase(unittest.TestCase):
 
     def test_dunpgettext(self):
         self.assertEqualTypeToo(
-            u'VohD1', self.translations.dungettext('messages1', 'foo1', 'foos1', 1))
+            'VohD1', self.translations.dungettext('messages1', 'foo1', 'foos1', 1))
         self.assertEqualTypeToo(
-            u'VohsD1', self.translations.dungettext('messages1', 'foo1', 'foos1', 2))
+            'VohsD1', self.translations.dungettext('messages1', 'foo1', 'foos1', 2))
         self.assertEqualTypeToo(
-            u'VohCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
+            'VohCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
                                                        'foos1', 1))
         self.assertEqualTypeToo(
-            u'VohsCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
+            'VohsCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
                                                         'foos1', 2))
 
     @pytest.mark.skipif(SKIP_LGETTEXT, reason="lgettext is deprecated")
@@ -219,9 +219,9 @@ class NullTranslationsTestCase(unittest.TestCase):
 
     def test_same_return_values(self):
         data = {
-            'message': u'foo', 'domain': u'domain', 'context': 'tests',
-            'singular': u'bar', 'plural': u'baz', 'num': 1,
-            'msgid1': u'bar', 'msgid2': u'baz', 'n': 1,
+            'message': 'foo', 'domain': 'domain', 'context': 'tests',
+            'singular': 'bar', 'plural': 'baz', 'num': 1,
+            'msgid1': 'bar', 'msgid2': 'baz', 'n': 1,
         }
         for name in self.method_names():
             method = getattr(self.translations, name)
@@ -346,9 +346,9 @@ def test_lazy_proxy():
         return f"Hello, {name}!"
 
     lazy_greeting = support.LazyProxy(greeting, name='Joe')
-    assert str(lazy_greeting) == u"Hello, Joe!"
-    assert u'  ' + lazy_greeting == u'  Hello, Joe!'
-    assert u'(%s)' % lazy_greeting == u'(Hello, Joe!)'
+    assert str(lazy_greeting) == "Hello, Joe!"
+    assert '  ' + lazy_greeting == '  Hello, Joe!'
+    assert '(%s)' % lazy_greeting == '(Hello, Joe!)'
     assert f"[{lazy_greeting}]" == "[Hello, Joe!]"
 
     greetings = [
@@ -358,9 +358,9 @@ def test_lazy_proxy():
     ]
     greetings.sort()
     assert [str(g) for g in greetings] == [
-        u"Hello, Joe!",
-        u"Hello, universe!",
-        u"Hello, world!",
+        "Hello, Joe!",
+        "Hello, universe!",
+        "Hello, world!",
     ]
 
 
index f58fc2443c7611abdd0c12720929b589d1871be5..d21c723f3e4c480c9d237683df307d521872e343 100644 (file)
@@ -62,15 +62,15 @@ def parse_encoding(s):
 
 
 def test_parse_encoding_defined():
-    assert parse_encoding(u'# coding: utf-8') == 'utf-8'
+    assert parse_encoding('# coding: utf-8') == 'utf-8'
 
 
 def test_parse_encoding_undefined():
-    assert parse_encoding(u'') is None
+    assert parse_encoding('') is None
 
 
 def test_parse_encoding_non_ascii():
-    assert parse_encoding(u'K\xf6ln') is None
+    assert parse_encoding('K\xf6ln') is None
 
 
 @pytest.mark.parametrize('source, result', [