diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-08-15 01:55:57 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2016-08-15 01:56:36 +0100 |
| commit | 78649f8e905f04c3000abef23725d557a103abef (patch) | |
| tree | 60afa4c1829f9a0068ae9ea34ef3374eb86fd0f8 /tests/test_cursor.py | |
| parent | 3b41c3a6f373af0100a399cea150a9420ecc4acb (diff) | |
| download | psycopg2-78649f8e905f04c3000abef23725d557a103abef.tar.gz | |
Dropped use of b() "macro" and 2to3 fixer
Just use the b"" strings syntax supported from python 2.6.
Diffstat (limited to 'tests/test_cursor.py')
| -rwxr-xr-x | tests/test_cursor.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 970cc37..3201013 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -26,7 +26,6 @@ import time import pickle import psycopg2 import psycopg2.extensions -from psycopg2.extensions import b from testutils import unittest, ConnectingTestCase, skip_before_postgres from testutils import skip_if_no_namedtuple, skip_if_no_getrefcount @@ -63,28 +62,28 @@ class CursorTests(ConnectingTestCase): # unicode query containing only ascii data cur.execute(u"SELECT 'foo';") self.assertEqual('foo', cur.fetchone()[0]) - self.assertEqual(b("SELECT 'foo';"), cur.mogrify(u"SELECT 'foo';")) + self.assertEqual(b"SELECT 'foo';", cur.mogrify(u"SELECT 'foo';")) conn.set_client_encoding('UTF8') snowman = u"\u2603" # unicode query with non-ascii data cur.execute(u"SELECT '%s';" % snowman) - self.assertEqual(snowman.encode('utf8'), b(cur.fetchone()[0])) + self.assertEqual(snowman.encode('utf8'), cur.fetchone()[0].encode('utf8')) self.assertEqual(("SELECT '%s';" % snowman).encode('utf8'), - cur.mogrify(u"SELECT '%s';" % snowman).replace(b("E'"), b("'"))) + cur.mogrify(u"SELECT '%s';" % snowman).replace(b"E'", b"'")) # unicode args cur.execute("SELECT %s;", (snowman,)) - self.assertEqual(snowman.encode("utf-8"), b(cur.fetchone()[0])) + self.assertEqual(snowman.encode("utf-8"), cur.fetchone()[0].encode('utf8')) self.assertEqual(("SELECT '%s';" % snowman).encode('utf8'), - cur.mogrify("SELECT %s;", (snowman,)).replace(b("E'"), b("'"))) + cur.mogrify("SELECT %s;", (snowman,)).replace(b"E'", b"'")) # unicode query and args cur.execute(u"SELECT %s;", (snowman,)) - self.assertEqual(snowman.encode("utf-8"), b(cur.fetchone()[0])) + self.assertEqual(snowman.encode("utf-8"), cur.fetchone()[0].encode('utf8')) self.assertEqual(("SELECT '%s';" % snowman).encode('utf8'), - cur.mogrify(u"SELECT %s;", (snowman,)).replace(b("E'"), b("'"))) + cur.mogrify(u"SELECT %s;", (snowman,)).replace(b"E'", b"'")) def test_mogrify_decimal_explodes(self): # issue #7: explodes on windows with python 2.5 and psycopg 2.2.2 @@ -95,7 +94,7 @@ class CursorTests(ConnectingTestCase): conn = self.conn cur = conn.cursor() - self.assertEqual(b('SELECT 10.3;'), + self.assertEqual(b'SELECT 10.3;', cur.mogrify("SELECT %s;", (Decimal("10.3"),))) @skip_if_no_getrefcount |
