summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/test_cursor.py5
-rwxr-xr-xtests/test_sql.py5
-rw-r--r--tests/testutils.py5
3 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py
index ec76918..d522386 100755
--- a/tests/test_cursor.py
+++ b/tests/test_cursor.py
@@ -29,9 +29,10 @@ import psycopg2.extensions
import unittest
from .testutils import (ConnectingTestCase, skip_before_postgres,
skip_if_no_getrefcount, slow, skip_if_no_superuser,
- skip_if_windows, unicode)
+ skip_if_windows)
import psycopg2.extras
+from psycopg2.compat import text_type
class CursorTests(ConnectingTestCase):
@@ -75,7 +76,7 @@ class CursorTests(ConnectingTestCase):
snowman = u"\u2603"
def b(s):
- if isinstance(s, unicode):
+ if isinstance(s, text_type):
return s.encode('utf8')
else:
return s
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 1c20997..81b22a4 100755
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -26,10 +26,11 @@ import datetime as dt
import unittest
from .testutils import (ConnectingTestCase,
skip_before_postgres, skip_before_python, skip_copy_if_green,
- unicode, StringIO)
+ StringIO)
import psycopg2
from psycopg2 import sql
+from psycopg2.compat import text_type
class SqlFormatTests(ConnectingTestCase):
@@ -64,7 +65,7 @@ class SqlFormatTests(ConnectingTestCase):
s = sql.SQL(u"select {0} from {1}").format(
sql.Identifier(u'field'), sql.Identifier('table'))
s1 = s.as_string(self.conn)
- self.assert_(isinstance(s1, unicode))
+ self.assert_(isinstance(s1, text_type))
self.assertEqual(s1, u'select "field" from "table"')
def test_compose_literal(self):
diff --git a/tests/testutils.py b/tests/testutils.py
index d70e091..3bb72e2 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -30,6 +30,7 @@ import platform
import unittest
from functools import wraps
from .testconfig import dsn, repl_dsn
+from psycopg2.compat import text_type
# Python 2/3 compatibility
@@ -39,14 +40,12 @@ if sys.version_info[0] == 2:
long = long
reload = reload
unichr = unichr
- unicode = unicode
else:
# Python 3
from io import StringIO
from importlib import reload
long = int
unichr = chr
- unicode = str
# Silence warnings caused by the stubbornness of the Python unittest
@@ -89,7 +88,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, unicode):
+ if isinstance(s, text_type):
return re.sub(r"\bE'", "'", s)
elif isinstance(first, bytes):
return re.sub(br"\bE'", b"'", s)