diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rwxr-xr-x | tests/test_quote.py | 13 |
2 files changed, 17 insertions, 2 deletions
@@ -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 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] |