Skip to content

Commit

Permalink
test: Enable unicode tests in psycopg2
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <ferenc.geczi@ibm.com>
  • Loading branch information
Ferenc- committed Sep 6, 2023
1 parent cf05392 commit d884a3d
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions tests/clients/test_psycopg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,32 +210,27 @@ def test_error_capture(self):
# Added to validate unicode support and register_type.
def test_unicode(self):
ext.register_type(ext.UNICODE, self.cursor)
#
# Python 2 chokes on Unicode and CircleCI tests are hanging (but pass locally).
# Disable these tests for now as we want to really just test register_type
# anyways
#
# snowman = "\u2603"
#
# self.cursor.execute("delete from users where id in (1,2,3)")
#
# # unicode in statement
# psycopg2.extras.execute_batch(self.cursor,
# "insert into users (id, name) values (%%s, %%s) -- %s" % snowman, [(1, 'x')])
# self.cursor.execute("select id, name from users where id = 1")
# self.assertEqual(self.cursor.fetchone(), (1, 'x'))
#
# # unicode in data
# psycopg2.extras.execute_batch(self.cursor,
# "insert into users (id, name) values (%s, %s)", [(2, snowman)])
# self.cursor.execute("select id, name from users where id = 2")
# self.assertEqual(self.cursor.fetchone(), (2, snowman))
#
# # unicode in both
# psycopg2.extras.execute_batch(self.cursor,
# "insert into users (id, name) values (%%s, %%s) -- %s" % snowman, [(3, snowman)])
# self.cursor.execute("select id, name from users where id = 3")
# self.assertEqual(self.cursor.fetchone(), (3, snowman))
snowman = "\u2603"

self.cursor.execute("delete from users where id in (1,2,3)")

# unicode in statement
psycopg2.extras.execute_batch(self.cursor,
"insert into users (id, name) values (%%s, %%s) -- %s" % snowman, [(1, 'x')])
self.cursor.execute("select id, name from users where id = 1")
self.assertEqual(self.cursor.fetchone(), (1, 'x'))

# unicode in data
psycopg2.extras.execute_batch(self.cursor,
"insert into users (id, name) values (%s, %s)", [(2, snowman)])
self.cursor.execute("select id, name from users where id = 2")
self.assertEqual(self.cursor.fetchone(), (2, snowman))

# unicode in both
psycopg2.extras.execute_batch(self.cursor,
"insert into users (id, name) values (%%s, %%s) -- %s" % snowman, [(3, snowman)])
self.cursor.execute("select id, name from users where id = 3")
self.assertEqual(self.cursor.fetchone(), (3, snowman))

def test_register_type(self):
import uuid
Expand Down

0 comments on commit d884a3d

Please sign in to comment.