summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames Henstridge <james@jamesh.id.au>2008-04-20 23:19:42 +0000
committerJames Henstridge <james@jamesh.id.au>2008-04-20 23:19:42 +0000
commit331c942800b9115eb3facee9f36c555c1a6e24c3 (patch)
tree58323663e0ea4031f0e6563e0a354f5915272c15 /tests
parent2f3f4c1258ee6455b8b956c9f9d70a372b5a80f5 (diff)
downloadpsycopg2-331c942800b9115eb3facee9f36c555c1a6e24c3.tar.gz
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.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_quote.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/test_quote.py b/tests/test_quote.py
index 62e7776..6da10fa 100755
--- a/tests/test_quote.py
+++ b/tests/test_quote.py
@@ -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]