Changeset 847 for trunk/tests


Ignore:
Timestamp:
Feb 9, 2016, 5:51:46 AM (4 years ago)
Author:
cito
Message:

Fix issue with arrays and records containing unicode

Arrays and records with non-ascii unicode elements
did not work properly in Python 2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_dbapi20.py

    r846 r847  
    733733            con.close()
    734734        self.assertEqual(row, values)
     735
     736    def test_unicode_list_and_tuple(self):
     737        value = (u'KÀse', u'WÃŒrstchen')
     738        con = self._connect()
     739        try:
     740            cur = con.cursor()
     741            try:
     742                cur.execute("select %s, %s", value)
     743            except pgdb.DatabaseError:
     744                self.skipTest('database does not support latin-1')
     745            row = cur.fetchone()
     746            cur.execute("select %s, %s", (list(value), tuple(value)))
     747            as_list, as_tuple = cur.fetchone()
     748        finally:
     749            con.close()
     750        self.assertEqual(as_list, list(row))
     751        self.assertEqual(as_tuple, tuple(row))
    735752
    736753    def test_insert_record(self):
Note: See TracChangeset for help on using the changeset viewer.