diff options
author | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-10-15 11:52:18 +0200 |
---|---|---|
committer | Oleksandr Shulgin <oleksandr.shulgin@zalando.de> | 2015-10-15 11:52:18 +0200 |
commit | 89bb6b0711f8ba59f7b8e81339ddaa53356233a2 (patch) | |
tree | 8812ca7b8a9aedea9bc2e08a7e1312787bfeafca /tests/test_quote.py | |
parent | 9295bce154182863e19342b6a4c2e80a58187120 (diff) | |
download | psycopg2-89bb6b0711f8ba59f7b8e81339ddaa53356233a2.tar.gz |
Proper unicode handling in quote_ident.
Diffstat (limited to 'tests/test_quote.py')
-rwxr-xr-x | tests/test_quote.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_quote.py b/tests/test_quote.py index a24ab6d..6e94562 100755 --- a/tests/test_quote.py +++ b/tests/test_quote.py @@ -23,7 +23,7 @@ # License for more details. import sys -from testutils import unittest, ConnectingTestCase +from testutils import unittest, ConnectingTestCase, skip_before_libpq import psycopg2 import psycopg2.extensions @@ -166,11 +166,22 @@ class TestQuotedString(ConnectingTestCase): class TestQuotedIdentifier(ConnectingTestCase): + @skip_before_libpq(9, 0) def test_identifier(self): from psycopg2.extensions import quote_ident self.assertEqual(quote_ident('blah-blah', self.conn), '"blah-blah"') self.assertEqual(quote_ident('quote"inside', self.conn), '"quote""inside"') + @skip_before_libpq(9, 0) + def test_unicode_ident(self): + from psycopg2.extensions import quote_ident + snowman = u"\u2603" + quoted = '"' + snowman + '"' + if sys.version_info[0] < 3: + self.assertEqual(quote_ident(snowman, self.conn), quoted.encode('utf8')) + else: + self.assertEqual(quote_ident(snowman, self.conn), quoted) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |