summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2023-01-18 20:27:44 +0200
committerAarni Koskela <akx@iki.fi>2023-01-18 21:20:51 +0200
commit82d345a66e850f643607ac9fcafd9b9a2a89d1e1 (patch)
treead66b7a13fb05f30628b6710dacab554505d55e8 /tests
parentcb0269fc63f5af4ade770f7a8872de8090bf697d (diff)
downloadbabel-82d345a66e850f643607ac9fcafd9b9a2a89d1e1.tar.gz
Apply some small miscellaneous formatting fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/messages/test_catalog.py6
-rw-r--r--tests/test_dates.py12
-rw-r--r--tests/test_localedata.py9
-rw-r--r--tests/test_numbers.py22
-rw-r--r--tests/test_support.py12
-rw-r--r--tests/test_util.py9
6 files changed, 36 insertions, 34 deletions
diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py
index 29cfc0d..273c83f 100644
--- a/tests/messages/test_catalog.py
+++ b/tests/messages/test_catalog.py
@@ -98,7 +98,7 @@ class CatalogTestCase(unittest.TestCase):
def test_update_message_changed_to_simple(self):
cat = catalog.Catalog()
- cat.add('foo' u'foos', ('Voh', 'Vöhs'))
+ cat.add('foo' 'foos', ('Voh', 'Vöhs'))
tmpl = catalog.Catalog()
tmpl.add('foo')
cat.update(tmpl)
@@ -112,11 +112,11 @@ class CatalogTestCase(unittest.TestCase):
assert cat['foo'].user_comments == []
# Update cat[u'foo'] with a new location and a comment
cat['foo'] = catalog.Message('foo', locations=[('main.py', 7)],
- user_comments=['Foo Bar comment 1'])
+ user_comments=['Foo Bar comment 1'])
assert cat['foo'].user_comments == ['Foo Bar comment 1']
# now add yet another location with another comment
cat['foo'] = catalog.Message('foo', locations=[('main.py', 9)],
- auto_comments=['Foo Bar comment 2'])
+ auto_comments=['Foo Bar comment 2'])
assert cat['foo'].auto_comments == ['Foo Bar comment 2']
def test_update_fuzzy_matching_with_case_change(self):
diff --git a/tests/test_dates.py b/tests/test_dates.py
index fd85a1b..2e3c880 100644
--- a/tests/test_dates.py
+++ b/tests/test_dates.py
@@ -68,7 +68,7 @@ class DateTimeFormatTestCase:
assert dates.DateTimeFormat(d, locale='en_US')['w'] == '53'
def test_week_of_year_de_first_us_last_with_year(self):
- d = date(2018,12,31)
+ d = date(2018, 12, 31)
fmt = dates.DateTimeFormat(d, locale='de_DE')
assert fmt['w'] == '1'
assert fmt['YYYY'] == '2019'
@@ -571,8 +571,10 @@ def test_format_datetime(timezone_getter):
tzinfo=timezone_getter('Europe/Paris'),
locale='fr_FR'
)
- assert full == ('dimanche 1 avril 2007 à 17:30:00 heure '
- u'd\u2019\xe9t\xe9 d\u2019Europe centrale')
+ assert full == (
+ 'dimanche 1 avril 2007 à 17:30:00 heure '
+ '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'),
@@ -727,8 +729,8 @@ def test_no_inherit_metazone_formatting(timezone_getter):
def test_russian_week_numbering():
# See https://github.com/python-babel/babel/issues/485
v = date(2017, 1, 1)
- assert dates.format_date(v, format='YYYY-ww',locale='ru_RU') == '2016-52' # This would have returned 2017-01 prior to CLDR 32
- assert dates.format_date(v, format='YYYY-ww',locale='de_DE') == '2016-52'
+ assert dates.format_date(v, format='YYYY-ww', locale='ru_RU') == '2016-52' # This would have returned 2017-01 prior to CLDR 32
+ assert dates.format_date(v, format='YYYY-ww', locale='de_DE') == '2016-52'
def test_en_gb_first_weekday():
diff --git a/tests/test_localedata.py b/tests/test_localedata.py
index 7672ddc..36f3e73 100644
--- a/tests/test_localedata.py
+++ b/tests/test_localedata.py
@@ -94,19 +94,18 @@ def test_locale_argument_acceptance():
# Testing None input.
normalized_locale = localedata.normalize_locale(None)
assert normalized_locale is None
- locale_exist = localedata.exists(None)
- assert locale_exist is False
+ assert not localedata.exists(None)
- # # Testing list input.
+ # Testing list input.
normalized_locale = localedata.normalize_locale(['en_us', None])
assert normalized_locale is None
- locale_exist = localedata.exists(['en_us', None])
- assert locale_exist is False
+ assert not localedata.exists(['en_us', None])
def test_locale_identifiers_cache(monkeypatch):
original_listdir = localedata.os.listdir
listdir_calls = []
+
def listdir_spy(*args):
rv = original_listdir(*args)
listdir_calls.append((args, rv))
diff --git a/tests/test_numbers.py b/tests/test_numbers.py
index a6f79f0..04a1865 100644
--- a/tests/test_numbers.py
+++ b/tests/test_numbers.py
@@ -167,6 +167,7 @@ class FormatDecimalTestCase(unittest.TestCase):
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):
def test_can_parse_decimals(self):
@@ -231,15 +232,15 @@ def test_validate_currency():
def test_is_currency():
- assert is_currency('EUR') is True
- assert is_currency('eUr') is False
- assert is_currency('FUU') is False
- assert is_currency('') is False
- assert is_currency(None) is False
- assert is_currency(' EUR ') is False
- assert is_currency(' ') is False
- assert is_currency([]) is False
- assert is_currency(set()) is False
+ assert is_currency('EUR')
+ assert not is_currency('eUr')
+ assert not is_currency('FUU')
+ assert not is_currency('')
+ assert not is_currency(None)
+ assert not is_currency(' EUR ')
+ assert not is_currency(' ')
+ assert not is_currency([])
+ assert not is_currency(set())
def test_normalize_currency():
@@ -451,8 +452,7 @@ def test_format_compact_currency():
def test_format_compact_currency_invalid_format_type():
with pytest.raises(numbers.UnknownCurrencyFormatError):
- numbers.format_compact_currency(1099.98, 'USD', locale='en_US',
- format_type='unknown')
+ numbers.format_compact_currency(1099.98, 'USD', locale='en_US', format_type='unknown')
@pytest.mark.parametrize('input_value, expected_value', [
diff --git a/tests/test_support.py b/tests/test_support.py
index 36bdcf6..0b7cba0 100644
--- a/tests/test_support.py
+++ b/tests/test_support.py
@@ -27,6 +27,7 @@ from babel.messages.mofile import write_mo
SKIP_LGETTEXT = sys.version_info >= (3, 8)
+
@pytest.mark.usefixtures("os_environ")
class TranslationsTestCase(unittest.TestCase):
@@ -73,7 +74,7 @@ class TranslationsTestCase(unittest.TestCase):
def test_upgettext(self):
self.assertEqualTypeToo('Voh', self.translations.ugettext('foo'))
self.assertEqualTypeToo('VohCTX', self.translations.upgettext('foo',
- 'foo'))
+ 'foo'))
@pytest.mark.skipif(SKIP_LGETTEXT, reason="lgettext is deprecated")
def test_lpgettext(self):
@@ -156,10 +157,10 @@ class TranslationsTestCase(unittest.TestCase):
'VohsD1', self.translations.dungettext('messages1', 'foo1', 'foos1', 2))
self.assertEqualTypeToo(
'VohCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
- 'foos1', 1))
+ 'foos1', 1))
self.assertEqualTypeToo(
'VohsCTXD1', self.translations.dunpgettext('messages1', 'foo', 'foo1',
- 'foos1', 2))
+ 'foos1', 2))
@pytest.mark.skipif(SKIP_LGETTEXT, reason="lgettext is deprecated")
def test_ldnpgettext(self):
@@ -351,12 +352,11 @@ def test_lazy_proxy():
assert '(%s)' % lazy_greeting == '(Hello, Joe!)'
assert f"[{lazy_greeting}]" == "[Hello, Joe!]"
- greetings = [
+ greetings = sorted([
support.LazyProxy(greeting, 'world'),
support.LazyProxy(greeting, 'Joe'),
support.LazyProxy(greeting, 'universe'),
- ]
- greetings.sort()
+ ])
assert [str(g) for g in greetings] == [
"Hello, Joe!",
"Hello, universe!",
diff --git a/tests/test_util.py b/tests/test_util.py
index d21c723..ae861dd 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -22,11 +22,12 @@ from babel.util import parse_future_flags
class _FF:
- division = __future__.division.compiler_flag
- print_function = __future__.print_function.compiler_flag
- with_statement = __future__.with_statement.compiler_flag
+ division = __future__.division.compiler_flag
+ print_function = __future__.print_function.compiler_flag
+ with_statement = __future__.with_statement.compiler_flag
unicode_literals = __future__.unicode_literals.compiler_flag
+
def test_distinct():
assert list(util.distinct([1, 2, 1, 3, 4, 4])) == [1, 2, 3, 4]
assert list(util.distinct('foobar')) == ['f', 'o', 'b', 'a', 'r']
@@ -48,7 +49,7 @@ def test_pathmatch():
class FixedOffsetTimezoneTestCase(unittest.TestCase):
def test_zone_negative_offset(self):
- assert util.FixedOffsetTimezone((-60)).zone == 'Etc/GMT-60'
+ assert util.FixedOffsetTimezone(-60).zone == 'Etc/GMT-60'
def test_zone_zero_offset(self):
assert util.FixedOffsetTimezone(0).zone == 'Etc/GMT+0'