summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo van Kemenade <hugovk@users.noreply.github.com>2021-09-12 17:40:41 +0300
committerAarni Koskela <akx@iki.fi>2021-09-14 15:09:03 +0300
commit3af52a974d4606237f0d5381425e526adf28610f (patch)
treef9d3f14fd8dd08d53bba066b43f2dc9d532df503 /tests
parent96acf8688c0e4b96788fbc35bb6d1640ef46a091 (diff)
downloadbabel-3af52a974d4606237f0d5381425e526adf28610f.tar.gz
Remove redundant _compat.py
Diffstat (limited to 'tests')
-rw-r--r--tests/messages/test_catalog.py2
-rw-r--r--tests/messages/test_checkers.py2
-rw-r--r--tests/messages/test_extract.py2
-rw-r--r--tests/messages/test_frontend.py38
-rw-r--r--tests/messages/test_js_extract.py2
-rw-r--r--tests/messages/test_mofile.py12
-rw-r--r--tests/messages/test_pofile.py2
-rw-r--r--tests/test_core.py2
-rw-r--r--tests/test_numbers.py2
-rw-r--r--tests/test_plural.py2
-rw-r--r--tests/test_smoke.py2
-rw-r--r--tests/test_support.py19
-rw-r--r--tests/test_util.py2
13 files changed, 39 insertions, 50 deletions
diff --git a/tests/messages/test_catalog.py b/tests/messages/test_catalog.py
index 6619996..47e51bb 100644
--- a/tests/messages/test_catalog.py
+++ b/tests/messages/test_catalog.py
@@ -14,8 +14,8 @@
import copy
import datetime
import unittest
+from io import StringIO
-from babel._compat import StringIO
from babel.dates import format_datetime, UTC
from babel.messages import catalog, pofile
from babel.util import FixedOffsetTimezone
diff --git a/tests/messages/test_checkers.py b/tests/messages/test_checkers.py
index 49abb51..5354e78 100644
--- a/tests/messages/test_checkers.py
+++ b/tests/messages/test_checkers.py
@@ -14,6 +14,7 @@
from datetime import datetime
import time
import unittest
+from io import BytesIO
from babel import __version__ as VERSION
from babel.core import Locale, UnknownLocaleError
@@ -22,7 +23,6 @@ from babel.messages import checkers
from babel.messages.plurals import PLURALS
from babel.messages.pofile import read_po
from babel.util import LOCALTZ
-from babel._compat import BytesIO
class CheckersTestCase(unittest.TestCase):
diff --git a/tests/messages/test_extract.py b/tests/messages/test_extract.py
index ac7f0a6..5676717 100644
--- a/tests/messages/test_extract.py
+++ b/tests/messages/test_extract.py
@@ -14,9 +14,9 @@
import codecs
import sys
import unittest
+from io import BytesIO, StringIO
from babel.messages import extract
-from babel._compat import BytesIO, StringIO
class ExtractPythonTestCase(unittest.TestCase):
diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py
index b56554c..f8b1634 100644
--- a/tests/messages/test_frontend.py
+++ b/tests/messages/test_frontend.py
@@ -16,6 +16,7 @@ from datetime import datetime
from distutils.dist import Distribution
from distutils.errors import DistutilsOptionError
from distutils.log import _global_log
+from io import StringIO
import logging
import os
import shutil
@@ -28,10 +29,9 @@ import pytest
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, po_file_read_mode
+from babel.messages.frontend import CommandLineInterface, extract_messages, update_catalog
from babel.util import LOCALTZ
from babel.messages.pofile import read_po, write_po
-from babel._compat import StringIO
this_dir = os.path.abspath(os.path.dirname(__file__))
data_dir = os.path.join(this_dir, 'data')
@@ -122,7 +122,7 @@ class ExtractMessagesTestCase(unittest.TestCase):
self.cmd.finalize_options()
self.cmd.run()
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
catalog = read_po(f)
msg = catalog.get('bar')
self.assertEqual(1, len(msg.locations))
@@ -202,7 +202,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -255,7 +255,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -313,7 +313,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -344,7 +344,7 @@ msgstr[0] ""
msgstr[1] ""
"""
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -430,7 +430,7 @@ msgstr[1] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -482,7 +482,7 @@ msgstr[1] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -536,7 +536,7 @@ msgstr[2] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -587,7 +587,7 @@ msgstr[0] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='ja_JP')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -648,7 +648,7 @@ msgstr[1] ""
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en_US'),
'long_message': long_message}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -708,7 +708,7 @@ msgstr[1] ""
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en_US'),
'long_message': long_message}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -865,7 +865,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -915,7 +915,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -963,7 +963,7 @@ msgstr[1] ""
'year': time.strftime('%Y'),
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(pot_file, po_file_read_mode) as f:
+ with open(pot_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -1011,7 +1011,7 @@ msgstr[1] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -1058,7 +1058,7 @@ msgstr[0] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
@@ -1108,7 +1108,7 @@ msgstr[2] ""
""" % {'version': VERSION,
'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- with open(po_file, po_file_read_mode) as f:
+ with open(po_file) as f:
actual_content = f.read()
self.assertEqual(expected_content, actual_content)
diff --git a/tests/messages/test_js_extract.py b/tests/messages/test_js_extract.py
index d19c255..73b16a9 100644
--- a/tests/messages/test_js_extract.py
+++ b/tests/messages/test_js_extract.py
@@ -1,6 +1,6 @@
# -- encoding: UTF-8 --
+from io import BytesIO
import pytest
-from babel._compat import BytesIO
from babel.messages import extract
diff --git a/tests/messages/test_mofile.py b/tests/messages/test_mofile.py
index fb672a8..5cc796f 100644
--- a/tests/messages/test_mofile.py
+++ b/tests/messages/test_mofile.py
@@ -13,9 +13,9 @@
import os
import unittest
+from io import BytesIO
from babel.messages import mofile, Catalog
-from babel._compat import BytesIO, text_type
from babel.support import Translations
@@ -56,15 +56,15 @@ class WriteMoTestCase(unittest.TestCase):
buf.seek(0)
translations = Translations(fp=buf)
self.assertEqual(u'Voh', translations.ugettext('foo'))
- assert isinstance(translations.ugettext('foo'), text_type)
+ assert isinstance(translations.ugettext('foo'), str)
self.assertEqual(u'Es gibt', translations.ungettext('There is', 'There are', 1))
- assert isinstance(translations.ungettext('There is', 'There are', 1), text_type)
+ assert isinstance(translations.ungettext('There is', 'There are', 1), str)
self.assertEqual(u'Fizz', translations.ugettext('Fizz'))
- assert isinstance(translations.ugettext('Fizz'), text_type)
+ assert isinstance(translations.ugettext('Fizz'), str)
self.assertEqual(u'Fuzz', translations.ugettext('Fuzz'))
- assert isinstance(translations.ugettext('Fuzz'), text_type)
+ assert isinstance(translations.ugettext('Fuzz'), str)
self.assertEqual(u'Fuzzes', translations.ugettext('Fuzzes'))
- assert isinstance(translations.ugettext('Fuzzes'), text_type)
+ assert isinstance(translations.ugettext('Fuzzes'), str)
def test_more_plural_forms(self):
catalog2 = Catalog(locale='ru_RU')
diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py
index be1172a..4dd13d3 100644
--- a/tests/messages/test_pofile.py
+++ b/tests/messages/test_pofile.py
@@ -13,12 +13,12 @@
from datetime import datetime
import unittest
+from io import BytesIO, StringIO
from babel.core import Locale
from babel.messages.catalog import Catalog, Message
from babel.messages import pofile
from babel.util import FixedOffsetTimezone
-from babel._compat import StringIO, BytesIO
class ReadPoTestCase(unittest.TestCase):
diff --git a/tests/test_core.py b/tests/test_core.py
index 558322e..da7d0a2 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -302,8 +302,6 @@ def test_parse_locale():
'babel/locale-data/es_419.dat',
])
def test_compatible_classes_in_global_and_localedata(filename):
- # Use pickle module rather than cPickle since cPickle.Unpickler is a method
- # on Python 2
import pickle
class Unpickler(pickle.Unpickler):
diff --git a/tests/test_numbers.py b/tests/test_numbers.py
index 11e61d3..896a316 100644
--- a/tests/test_numbers.py
+++ b/tests/test_numbers.py
@@ -11,6 +11,7 @@
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
+import decimal
import unittest
import pytest
@@ -20,7 +21,6 @@ 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)
-from babel._compat import decimal
class FormatDecimalTestCase(unittest.TestCase):
diff --git a/tests/test_plural.py b/tests/test_plural.py
index bea8115..809f971 100644
--- a/tests/test_plural.py
+++ b/tests/test_plural.py
@@ -10,11 +10,11 @@
# 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 decimal
import unittest
import pytest
from babel import plural, localedata
-from babel._compat import decimal
EPSILON = decimal.Decimal("0.0001")
diff --git a/tests/test_smoke.py b/tests/test_smoke.py
index 23d82aa..f5319f2 100644
--- a/tests/test_smoke.py
+++ b/tests/test_smoke.py
@@ -5,13 +5,13 @@ 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
from datetime import datetime
import pytest
from babel import Locale
from babel import dates
from babel import numbers
-from babel._compat import decimal
@pytest.mark.all_locales
diff --git a/tests/test_support.py b/tests/test_support.py
index a683591..99217b3 100644
--- a/tests/test_support.py
+++ b/tests/test_support.py
@@ -19,13 +19,12 @@ import unittest
import pytest
import sys
from datetime import date, datetime, timedelta
+from io import BytesIO
from babel import support
from babel.messages import Catalog
from babel.messages.mofile import write_mo
-from babel._compat import BytesIO, PY2
-get_arg_spec = (inspect.getargspec if PY2 else inspect.getfullargspec)
SKIP_LGETTEXT = sys.version_info >= (3, 8)
@@ -219,8 +218,8 @@ class NullTranslationsTestCase(unittest.TestCase):
translations_method = getattr(self.translations, name)
null_method = getattr(self.null_translations, name)
self.assertEqual(
- get_arg_spec(translations_method),
- get_arg_spec(null_method),
+ inspect.getfullargspec(translations_method),
+ inspect.getfullargspec(null_method),
)
def test_same_return_values(self):
@@ -232,7 +231,7 @@ class NullTranslationsTestCase(unittest.TestCase):
for name in self.method_names():
method = getattr(self.translations, name)
null_method = getattr(self.null_translations, name)
- signature = get_arg_spec(method)
+ signature = inspect.getfullargspec(method)
parameter_names = [name for name in signature.args if name != 'self']
values = [data[name] for name in parameter_names]
self.assertEqual(method(*values), null_method(*values))
@@ -365,15 +364,7 @@ def test_catalog_merge_files():
t1 = support.Translations()
assert t1.files == []
t1._catalog["foo"] = "bar"
- if PY2:
- # Explicitly use the pure-Python `StringIO` class, as we need to
- # augment it with the `name` attribute, which we can't do for
- # `babel._compat.BytesIO`, which is `cStringIO.StringIO` under
- # `PY2`...
- from StringIO import StringIO
- fp = StringIO()
- else:
- fp = BytesIO()
+ fp = BytesIO()
write_mo(fp, Catalog())
fp.seek(0)
fp.name = "pro.mo"
diff --git a/tests/test_util.py b/tests/test_util.py
index b29278e..0e9a09e 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -13,11 +13,11 @@
import __future__
import unittest
+from io import BytesIO
import pytest
from babel import util
-from babel._compat import BytesIO
from babel.util import parse_future_flags