Skip to content

Commit

Permalink
2008-04-21 James Henstridge <james@jamesh.id.au>
Browse files Browse the repository at this point in the history
	* tests/test_quote.py (QuotingTestCase.test_unicode): If the
	server encoding is not UTF8, skip the unicode test and emit a
	warning.
  • Loading branch information
jhenstridge committed Apr 20, 2008
1 parent 2f3f4c1 commit 331c942
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 11 additions & 2 deletions tests/test_quote.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -55,6 +57,14 @@ def test_binary(self):
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.
"""
Expand All @@ -63,7 +73,6 @@ def test_unicode(self):
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]

Expand Down

0 comments on commit 331c942

Please sign in to comment.