diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2020-11-17 20:39:39 +0200 |
---|---|---|
committer | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2020-11-17 22:22:11 +0200 |
commit | 6c48b63ae4a70da6dbbc5b6eef20806d7f505950 (patch) | |
tree | 6976b00090753bf0f64a5b4f3745e71f96f0d2c0 /tests/testutils.py | |
parent | b05a5819317ab19fc7749e34fb67f4604d9bd10a (diff) | |
download | psycopg2-6c48b63ae4a70da6dbbc5b6eef20806d7f505950.tar.gz |
Drop support for EOL Python 2.7
Diffstat (limited to 'tests/testutils.py')
-rw-r--r-- | tests/testutils.py | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/tests/testutils.py b/tests/testutils.py index 2b5bbf9..b64d4fc 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -34,32 +34,16 @@ import platform import unittest from functools import wraps from ctypes.util import find_library +from io import StringIO # noqa +from io import TextIOBase # noqa +from importlib import reload # noqa import psycopg2 import psycopg2.errors import psycopg2.extensions -from psycopg2.compat import PY2, PY3, string_types, text_type from .testconfig import green, dsn, repl_dsn -# Python 2/3 compatibility - -if PY2: - # Python 2 - from StringIO import StringIO - TextIOBase = object - long = long - reload = reload - unichr = unichr - -else: - # Python 3 - from io import StringIO # noqa - from io import TextIOBase # noqa - from importlib import reload # noqa - long = int - unichr = chr - # Silence warnings caused by the stubbornness of the Python unittest # maintainers @@ -102,7 +86,7 @@ class ConnectingTestCase(unittest.TestCase): def assertQuotedEqual(self, first, second, msg=None): """Compare two quoted strings disregarding eventual E'' quotes""" def f(s): - if isinstance(s, text_type): + if isinstance(s, str): return re.sub(r"\bE'", "'", s) elif isinstance(first, bytes): return re.sub(br"\bE'", b"'", s) @@ -454,7 +438,7 @@ def skip_if_crdb(reason, conn=None, version=None): "== 20.1.3": the test will be skipped only if the version matches. """ - if not isinstance(reason, string_types): + if not isinstance(reason, str): raise TypeError("reason should be a string, got %r instead" % reason) if conn is not None: @@ -518,14 +502,13 @@ def _crdb_match_version(version, pattern): return op(version, ref) -class py3_raises_typeerror(object): +class raises_typeerror(object): def __enter__(self): pass def __exit__(self, type, exc, tb): - if PY3: - assert type is TypeError - return True + assert type is TypeError + return True def slow(f): |