mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
2008-04-21 James Henstridge <james@jamesh.id.au>
* tests/test_quote.py (QuotingTestCase.test_unicode): If the server encoding is not UTF8, skip the unicode test and emit a warning.
This commit is contained in:
parent
2f3f4c1258
commit
331c942800
|
@ -1,5 +1,11 @@
|
|||
2008-04-21 James Henstridge <james@jamesh.id.au>
|
||||
|
||||
* tests/test_quote.py (QuotingTestCase.test_unicode): If the
|
||||
server encoding is not UTF8, skip the unicode test and emit a
|
||||
warning.
|
||||
|
||||
2008-04-21 Jorgen Austvik <Jorgen.Austvik@sun.com>
|
||||
|
||||
* tests/*.py: use the DSN constructed in tests/__init__.py.
|
||||
|
||||
* tests/__init__.py: allow setting the host, port and user for the
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
import unittest
|
||||
import tests
|
||||
|
||||
class QuotingTestCase(unittest.TestCase):
|
||||
|
@ -55,6 +57,14 @@ class QuotingTestCase(unittest.TestCase):
|
|||
self.assert_(not self.conn.notices)
|
||||
|
||||
def test_unicode(self):
|
||||
curs = self.conn.cursor()
|
||||
curs.execute("SHOW server_encoding")
|
||||
server_encoding = curs.fetchone()[0]
|
||||
if server_encoding != "UTF8":
|
||||
warnings.warn("Unicode test skipped since server encoding is %s"
|
||||
% server_encoding)
|
||||
return
|
||||
|
||||
data = u"""some data with \t chars
|
||||
to escape into, 'quotes', \u20ac euro sign and \\ a backslash too.
|
||||
"""
|
||||
|
@ -63,7 +73,6 @@ class QuotingTestCase(unittest.TestCase):
|
|||
self.conn.set_client_encoding('UNICODE')
|
||||
|
||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||
curs = self.conn.cursor()
|
||||
curs.execute("SELECT %s::text;", (data,))
|
||||
res = curs.fetchone()[0]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user