summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-01-19 19:49:45 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2021-01-19 19:49:45 +0000
commit0af22b4cfc21a8798b6fab125275b735302575fa (patch)
treee4f22c61b3e6c07b6e44297b827aa16151f164cd /test/dialect/postgresql
parent0a180a58baa4532cb07d9ca94057392a27b42421 (diff)
parent442ca5c000aab9faa69d514e7902c9d903cbd987 (diff)
downloadsqlalchemy-0af22b4cfc21a8798b6fab125275b735302575fa.tar.gz
Merge "Disallow non-native psycopg2 Unicode in Python 3; update docs"
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_dialect.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index 08be41b75..075994cb9 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -114,6 +114,26 @@ class DialectTest(fixtures.TestBase):
]:
eq_(dialect._get_server_version_info(mock_conn(string)), version)
+ @testing.requires.python3
+ @testing.requires.psycopg2_compatibility
+ def test_pg_dialect_no_native_unicode_in_python3(self, testing_engine):
+ with testing.expect_raises_message(
+ exc.ArgumentError,
+ "psycopg2 native_unicode mode is required under Python 3",
+ ):
+ testing_engine(options=dict(use_native_unicode=False))
+
+ @testing.requires.python2
+ @testing.requires.psycopg2_compatibility
+ def test_pg_dialect_no_native_unicode_in_python2(self, testing_engine):
+ e = testing_engine(options=dict(use_native_unicode=False))
+ with e.connect() as conn:
+ eq_(
+ conn.exec_driver_sql(u"SELECT '🐍 voix m’a rĂ©veillĂ©'").scalar(),
+ u"🐍 voix m’a rĂ©veillĂ©".encode("utf-8"),
+ )
+
+ @testing.requires.python2
@testing.requires.psycopg2_compatibility
def test_pg_dialect_use_native_unicode_from_config(self):
config = {