From 5397d953650c3b7728e8285c55c32c5eeb687de9 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 15 Oct 2011 15:05:51 -0400 Subject: - Added client_encoding parameter to create_engine() when the postgresql+psycopg2 dialect is used; calls the psycopg2 set_client_encoding() method with the value upon connect. [ticket:1839] --- test/dialect/test_postgresql.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/dialect/test_postgresql.py') diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index b37344b27..487139102 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -1622,6 +1622,25 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): assert 'will create implicit sequence' in msgs assert 'will create implicit index' in msgs + @testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature') + @engines.close_open_connections + def test_client_encoding(self): + c = testing.db.connect() + current_encoding = c.connection.connection.encoding + c.close() + + # attempt to use an encoding that's not + # already set + if current_encoding == 'UTF8': + test_encoding = 'LATIN1' + else: + test_encoding = 'UTF8' + + e = engines.testing_engine( + options={'client_encoding':test_encoding} + ) + c = e.connect() + eq_(c.connection.connection.encoding, test_encoding) @testing.fails_on('+zxjdbc', "Can't infer the SQL type to use for an instance " -- cgit v1.2.1