From 3fb72cea613ba05480a9027aa927d2c8b817d693 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 18 Jan 2023 20:07:31 +0200 Subject: Apply ruff I category fixes --- tests/conftest.py | 1 + tests/messages/test_catalog.py | 2 +- tests/messages/test_frontend.py | 22 ++++++++++++++-------- tests/messages/test_js_extract.py | 2 ++ tests/messages/test_mofile.py | 2 +- tests/messages/test_pofile.py | 6 ++++-- tests/test_core.py | 2 +- tests/test_dates.py | 2 +- tests/test_day_periods.py | 3 ++- tests/test_localedata.py | 4 ++-- tests/test_numbers.py | 15 +++++++++++---- tests/test_plural.py | 3 ++- tests/test_smoke.py | 5 +++-- tests/test_support.py | 6 +++--- tests/test_util.py | 1 + 15 files changed, 49 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index 0506a83..67e3ce9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os + import pytest try: diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py index e9b15a8..eb1e308 100644 --- a/tests/messages/test_catalog.py +++ b/tests/messages/test_catalog.py @@ -15,7 +15,7 @@ import datetime import unittest from io import StringIO -from babel.dates import format_datetime, UTC +from babel.dates import UTC, format_datetime from babel.messages import catalog, pofile from babel.util import FixedOffsetTimezone diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 8727cb8..e540e71 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -9,26 +9,32 @@ # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. -import shlex -from datetime import datetime -from freezegun import freeze_time -from io import StringIO -from setuptools import Distribution import logging import os +import shlex import shutil import sys import time import unittest +from datetime import datetime +from io import StringIO import pytest +from freezegun import freeze_time +from setuptools import Distribution from babel import __version__ as VERSION from babel.dates import format_datetime -from babel.messages import frontend, Catalog -from babel.messages.frontend import CommandLineInterface, extract_messages, update_catalog, OptionError, BaseError -from babel.util import LOCALTZ +from babel.messages import Catalog, frontend +from babel.messages.frontend import ( + BaseError, + CommandLineInterface, + OptionError, + extract_messages, + update_catalog, +) from babel.messages.pofile import read_po, write_po +from babel.util import LOCALTZ TEST_PROJECT_DISTRIBUTION_DATA = { "name": "TestProject", diff --git a/tests/messages/test_js_extract.py b/tests/messages/test_js_extract.py index 95985c0..7d43921 100644 --- a/tests/messages/test_js_extract.py +++ b/tests/messages/test_js_extract.py @@ -1,5 +1,7 @@ from io import BytesIO + import pytest + from babel.messages import extract diff --git a/tests/messages/test_mofile.py b/tests/messages/test_mofile.py index 6e026a8..ff7c2ed 100644 --- a/tests/messages/test_mofile.py +++ b/tests/messages/test_mofile.py @@ -14,7 +14,7 @@ import os import unittest from io import BytesIO -from babel.messages import mofile, Catalog +from babel.messages import Catalog, mofile from babel.support import Translations diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py index a72368b..fb5799b 100644 --- a/tests/messages/test_pofile.py +++ b/tests/messages/test_pofile.py @@ -10,16 +10,18 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. -from datetime import datetime import unittest +from datetime import datetime from io import BytesIO, StringIO + import pytest from babel.core import Locale -from babel.messages.catalog import Catalog, Message from babel.messages import pofile +from babel.messages.catalog import Catalog, Message from babel.util import FixedOffsetTimezone + class ReadPoTestCase(unittest.TestCase): def test_preserve_locale(self): diff --git a/tests/test_core.py b/tests/test_core.py index a200718..f4d253c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -13,7 +13,7 @@ import pytest from babel import core -from babel.core import default_locale, Locale +from babel.core import Locale, default_locale def test_locale_provides_access_to_cldr_locale_data(): diff --git a/tests/test_dates.py b/tests/test_dates.py index a4fb9c5..b4abaf9 100644 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -16,7 +16,7 @@ from datetime import date, datetime, time, timedelta import freezegun import pytest -from babel import dates, Locale +from babel import Locale, dates from babel.dates import NO_INHERITANCE_MARKER, _localize from babel.util import FixedOffsetTimezone diff --git a/tests/test_day_periods.py b/tests/test_day_periods.py index 414c0f6..9b51e1d 100644 --- a/tests/test_day_periods.py +++ b/tests/test_day_periods.py @@ -1,8 +1,9 @@ from datetime import time -import babel.dates as dates import pytest +import babel.dates as dates + @pytest.mark.parametrize("locale, time, expected_period_id", [ ("de", time(7, 42), "morning1"), # (from, before) diff --git a/tests/test_localedata.py b/tests/test_localedata.py index 006a6b0..7672ddc 100644 --- a/tests/test_localedata.py +++ b/tests/test_localedata.py @@ -12,15 +12,15 @@ import os import pickle +import random import sys import tempfile import unittest -import random from operator import methodcaller import pytest -from babel import localedata, Locale, UnknownLocaleError +from babel import Locale, UnknownLocaleError, localedata class MergeResolveTestCase(unittest.TestCase): diff --git a/tests/test_numbers.py b/tests/test_numbers.py index 3ae9143..ca33c1e 100644 --- a/tests/test_numbers.py +++ b/tests/test_numbers.py @@ -12,14 +12,21 @@ import decimal import unittest -import pytest - from datetime import date +import pytest + from babel import localedata, numbers from babel.numbers import ( - list_currencies, validate_currency, UnknownCurrencyError, is_currency, normalize_currency, - get_currency_precision, get_decimal_precision, get_currency_unit_pattern) + UnknownCurrencyError, + get_currency_precision, + get_currency_unit_pattern, + get_decimal_precision, + is_currency, + list_currencies, + normalize_currency, + validate_currency, +) class FormatDecimalTestCase(unittest.TestCase): diff --git a/tests/test_plural.py b/tests/test_plural.py index 16601cf..e1e5ead 100644 --- a/tests/test_plural.py +++ b/tests/test_plural.py @@ -11,9 +11,10 @@ # history and logs, available at http://babel.edgewall.org/log/. import decimal import unittest + import pytest -from babel import plural, localedata +from babel import localedata, plural EPSILON = decimal.Decimal("0.0001") diff --git a/tests/test_smoke.py b/tests/test_smoke.py index aed676a..c916845 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -4,11 +4,12 @@ looking at improving test coverage. They just verify that basic operations don't fail due to odd corner cases on any locale that we ship. """ -import decimal import datetime +import decimal + import pytest -from babel import Locale, units, dates, numbers +from babel import Locale, dates, numbers, units NUMBERS = ( decimal.Decimal("-33.76"), # Negative Decimal diff --git a/tests/test_support.py b/tests/test_support.py index 3ca0be3..fe10402 100644 --- a/tests/test_support.py +++ b/tests/test_support.py @@ -13,18 +13,18 @@ import inspect import os import shutil +import sys import tempfile import unittest -import pytest -import sys from datetime import date, datetime, timedelta from io import BytesIO +import pytest + from babel import support from babel.messages import Catalog from babel.messages.mofile import write_mo - SKIP_LGETTEXT = sys.version_info >= (3, 8) @pytest.mark.usefixtures("os_environ") diff --git a/tests/test_util.py b/tests/test_util.py index ba62d9b..f58fc24 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -11,6 +11,7 @@ # history and logs, available at http://babel.edgewall.org/log/. import __future__ + import unittest from io import BytesIO -- cgit v1.2.1