mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 23:55:46 +03:00
Added test for BYTES typecaster
This commit is contained in:
parent
fd31a7d41b
commit
4ab4247189
|
@ -170,6 +170,17 @@ class QuotingTestCase(ConnectingTestCase):
|
||||||
self.assertEqual(res, data)
|
self.assertEqual(res, data)
|
||||||
self.assert_(not self.conn.notices)
|
self.assert_(not self.conn.notices)
|
||||||
|
|
||||||
|
def test_bytes(self):
|
||||||
|
snowman = u"\u2603"
|
||||||
|
conn = self.connect()
|
||||||
|
conn.set_client_encoding('UNICODE')
|
||||||
|
psycopg2.extensions.register_type(psycopg2.extensions.BYTES, conn)
|
||||||
|
curs = conn.cursor()
|
||||||
|
curs.execute("select %s::text", (snowman,))
|
||||||
|
x = curs.fetchone()[0]
|
||||||
|
self.assert_(isinstance(x, bytes))
|
||||||
|
self.assertEqual(x, snowman.encode('utf8'))
|
||||||
|
|
||||||
|
|
||||||
class TestQuotedString(ConnectingTestCase):
|
class TestQuotedString(ConnectingTestCase):
|
||||||
def test_encoding_from_conn(self):
|
def test_encoding_from_conn(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user