summaryrefslogtreecommitdiff
path: root/tests/test_quote.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2013-04-05 00:00:42 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2013-04-05 00:00:42 +0100
commit736a78f3f60be23fe1e71f49c597ae8ae148784a (patch)
treeb706ba4b37380effd86aad5cebd48c628379a9e0 /tests/test_quote.py
parent7a5a226b49f0e6e0bedb76c78586f46cf64c7958 (diff)
downloadpsycopg2-736a78f3f60be23fe1e71f49c597ae8ae148784a.tar.gz
Avoid encoding strdup in qstring adapter
Dropped encoding parameter in the constructor: it is used nowhere and not documented. Use directly the connection encoding if available, else the previous latin1 fallback.
Diffstat (limited to 'tests/test_quote.py')
-rwxr-xr-xtests/test_quote.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_quote.py b/tests/test_quote.py
index 4b44a86..21b0d3f 100755
--- a/tests/test_quote.py
+++ b/tests/test_quote.py
@@ -162,6 +162,22 @@ class QuotingTestCase(unittest.TestCase):
self.assert_(not self.conn.notices)
+class TestQuotedString(unittest.TestCase):
+ def setUp(self):
+ self.conn = psycopg2.connect(dsn)
+
+ def tearDown(self):
+ self.conn.close()
+
+ def test_encoding(self):
+ q = psycopg2.extensions.QuotedString('hi')
+ self.assertEqual(q.encoding, 'latin1')
+
+ self.conn.set_client_encoding('utf_8')
+ q.prepare(self.conn)
+ self.assertEqual(q.encoding, 'utf_8')
+
+
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)