summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 19:53:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-04-27 19:53:57 -0400
commit4b614b9b35cd2baddb7ca67c04bee5d70ec6a172 (patch)
tree7483cd269f5823f903f96709eb864fff9b6d9383 /test/sql
parent9716a5c45e6185c5871555722d8495880f0e8c7a (diff)
downloadsqlalchemy-4b614b9b35cd2baddb7ca67c04bee5d70ec6a172.tar.gz
- the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_compiler.py18
-rw-r--r--test/sql/test_defaults.py28
-rw-r--r--test/sql/test_functions.py4
-rw-r--r--test/sql/test_generative.py16
-rw-r--r--test/sql/test_metadata.py4
-rw-r--r--test/sql/test_query.py42
-rw-r--r--test/sql/test_quote.py10
-rw-r--r--test/sql/test_rowcount.py6
-rw-r--r--test/sql/test_selectable.py34
-rw-r--r--test/sql/test_types.py91
-rw-r--r--test/sql/test_unicode.py80
-rw-r--r--test/sql/test_update.py12
12 files changed, 176 insertions, 169 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index 9cd893c1a..329d7543e 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -661,13 +661,13 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
s = select([table1.c.myid]).as_scalar()
try:
s.c.foo
- except exc.InvalidRequestError, err:
+ except exc.InvalidRequestError as err:
assert str(err) \
== 'Scalar Select expression has no columns; use this '\
'object directly within a column-level expression.'
try:
s.columns.foo
- except exc.InvalidRequestError, err:
+ except exc.InvalidRequestError as err:
assert str(err) \
== 'Scalar Select expression has no columns; use this '\
'object directly within a column-level expression.'
@@ -1116,9 +1116,9 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
# test unicode
self.assert_compile(select(
- [u"foobar(a)", u"pk_foo_bar(syslaal)"],
- u"a = 12",
- from_obj=[u"foobar left outer join lala on foobar.foo = lala.foo"]
+ ["foobar(a)", "pk_foo_bar(syslaal)"],
+ "a = 12",
+ from_obj=["foobar left outer join lala on foobar.foo = lala.foo"]
),
"SELECT foobar(a), pk_foo_bar(syslaal) FROM foobar "
"left outer join lala on foobar.foo = lala.foo WHERE a = 12"
@@ -2245,7 +2245,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
func.lala(table1.c.name).label('gg')])
eq_(
- s1.c.keys(),
+ list(s1.c.keys()),
['myid', 'foobar', str(f1), 'gg']
)
@@ -2273,7 +2273,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
t = table1
s1 = select([col], from_obj=t)
- assert s1.c.keys() == [key], s1.c.keys()
+ assert list(s1.c.keys()) == [key], list(s1.c.keys())
if label:
self.assert_compile(s1,
@@ -2679,11 +2679,11 @@ class DDLTest(fixtures.TestBase, AssertsCompiledSQL):
def test_reraise_of_column_spec_issue_unicode(self):
MyType = self._illegal_type_fixture()
t1 = Table('t', MetaData(),
- Column(u'méil', MyType())
+ Column('méil', MyType())
)
assert_raises_message(
exc.CompileError,
- ur"\(in table 't', column 'méil'\): Couldn't compile type",
+ r"\(in table 't', column 'méil'\): Couldn't compile type",
schema.CreateTable(t1).compile
)
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 1c31314d8..38c56f8be 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -600,7 +600,7 @@ class AutoIncrementTest(fixtures.TablesTest):
nonai.insert().execute(data='row 1')
nonai.insert().execute(data='row 2')
assert False
- except sa.exc.DBAPIError, e:
+ except sa.exc.DBAPIError as e:
assert True
nonai.insert().execute(id=1, data='row 1')
@@ -649,7 +649,7 @@ class SequenceExecTest(fixtures.TestBase):
def _assert_seq_result(self, ret):
"""asserts return of next_value is an int"""
- assert isinstance(ret, (int, long))
+ assert isinstance(ret, int)
assert ret > 0
def test_implicit_connectionless(self):
@@ -781,7 +781,7 @@ class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
]
start = seq.start or 1
inc = seq.increment or 1
- assert values == list(xrange(start, start + inc * 3, inc))
+ assert values == list(range(start, start + inc * 3, inc))
finally:
seq.drop(testing.db)
@@ -1156,20 +1156,22 @@ class UnicodeDefaultsTest(fixtures.TestBase):
c = Column(Unicode(32))
def test_unicode_default(self):
- # Py3K
- #default = 'foo'
- # Py2K
- default = u'foo'
- # end Py2K
+# start Py3K
+ default = 'foo'
+# end Py3K
+# start Py2K
+# default = u'foo'
+# end Py2K
c = Column(Unicode(32), default=default)
def test_nonunicode_default(self):
- # Py3K
- #default = b'foo'
- # Py2K
- default = 'foo'
- # end Py2K
+# start Py3K
+ default = b'foo'
+# end Py3K
+# start Py2K
+# default = 'foo'
+# end Py2K
assert_raises_message(
sa.exc.SAWarning,
"Unicode column received non-unicode default value.",
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py
index b325b7763..ee503dbb7 100644
--- a/test/sql/test_functions.py
+++ b/test/sql/test_functions.py
@@ -381,7 +381,7 @@ class ExecuteTest(fixtures.TestBase):
assert t.select(t.c.id == id).execute().first()['value'] == 9
t.update(values={t.c.value: func.length("asdf")}).execute()
assert t.select().execute().first()['value'] == 4
- print "--------------------------"
+ print("--------------------------")
t2.insert().execute()
t2.insert(values=dict(value=func.length("one"))).execute()
t2.insert(values=dict(value=func.length("asfda") + -19)).\
@@ -409,7 +409,7 @@ class ExecuteTest(fixtures.TestBase):
t2.update(values={t2.c.value: func.length("asfdaasdf"),
t2.c.stuff: "foo"}).execute()
- print "HI", select([t2.c.value, t2.c.stuff]).execute().first()
+ print("HI", select([t2.c.value, t2.c.stuff]).execute().first())
eq_(select([t2.c.value, t2.c.stuff]).execute().first(),
(9, "foo")
)
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 8b2abef0e..09b20d8ea 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -176,7 +176,7 @@ class BinaryEndpointTraversalTest(fixtures.TestBase):
canary = []
def visit(binary, l, r):
canary.append((binary.operator, l, r))
- print binary.operator, l, r
+ print(binary.operator, l, r)
sql_util.visit_binary_product(visit, expr)
eq_(
canary, expected
@@ -433,7 +433,7 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
clause2 = Vis().traverse(clause)
assert c1 == str(clause)
assert str(clause2) == c1 + " SOME MODIFIER=:lala"
- assert clause.bindparams.keys() == ['bar']
+ assert list(clause.bindparams.keys()) == ['bar']
assert set(clause2.bindparams.keys()) == set(['bar', 'lala'])
def test_select(self):
@@ -446,8 +446,8 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
s3 = Vis().traverse(s2)
assert str(s3) == s3_assert
assert str(s2) == s2_assert
- print str(s2)
- print str(s3)
+ print(str(s2))
+ print(str(s3))
class Vis(ClauseVisitor):
def visit_select(self, select):
select.append_whereclause(t1.c.col2 == 7)
@@ -459,8 +459,8 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
def visit_select(self, select):
select.append_whereclause(t1.c.col3 == 9)
s4 = Vis().traverse(s3)
- print str(s3)
- print str(s4)
+ print(str(s3))
+ print(str(s4))
assert str(s4) == s4_assert
assert str(s3) == s3_assert
@@ -471,8 +471,8 @@ class ClauseTest(fixtures.TestBase, AssertsCompiledSQL):
binary.left = t1.c.col1
binary.right = bindparam("col1", unique=True)
s5 = Vis().traverse(s4)
- print str(s4)
- print str(s5)
+ print(str(s4))
+ print(str(s5))
assert str(s5) == s5_assert
assert str(s4) == s4_assert
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index db2eaa4fa..c0873862d 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -89,7 +89,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
msgs.append("attach %s.%s" % (t.name, c.name))
c1 = Column('foo', String())
m = MetaData()
- for i in xrange(3):
+ for i in range(3):
cx = c1.copy()
# as of 0.7, these events no longer copy. its expected
# that listeners will be re-established from the
@@ -511,7 +511,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
def _get_key(i):
return [i.name, i.unique] + \
sorted(i.kwargs.items()) + \
- i.columns.keys()
+ list(i.columns.keys())
eq_(
sorted([_get_key(i) for i in table.indexes]),
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index 293e629c8..3e9045fa5 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -367,10 +367,10 @@ class QueryTest(fixtures.TestBase):
)
if use_labels:
eq_(result[0]['query_users_user_id'], 7)
- eq_(result[0].keys(), ["query_users_user_id", "query_users_user_name"])
+ eq_(list(result[0].keys()), ["query_users_user_id", "query_users_user_name"])
else:
eq_(result[0]['user_id'], 7)
- eq_(result[0].keys(), ["user_id", "user_name"])
+ eq_(list(result[0].keys()), ["user_id", "user_name"])
eq_(result[0][0], 7)
eq_(result[0][users.c.user_id], 7)
@@ -523,13 +523,13 @@ class QueryTest(fixtures.TestBase):
def a_eq(got, wanted):
if got != wanted:
- print "Wanted %s" % wanted
- print "Received %s" % got
+ print("Wanted %s" % wanted)
+ print("Received %s" % got)
self.assert_(got == wanted, got)
a_eq(prep('select foo'), 'select foo')
a_eq(prep("time='12:30:00'"), "time='12:30:00'")
- a_eq(prep(u"time='12:30:00'"), u"time='12:30:00'")
+ a_eq(prep("time='12:30:00'"), "time='12:30:00'")
a_eq(prep(":this:that"), ":this:that")
a_eq(prep(":this :that"), "? ?")
a_eq(prep("(:this),(:that :other)"), "(?),(? ?)")
@@ -769,7 +769,7 @@ class QueryTest(fixtures.TestBase):
).first()
eq_(r['user_id'], 1)
eq_(r['user_name'], "john")
- eq_(r.keys(), ["user_id", "user_name"])
+ eq_(list(r.keys()), ["user_id", "user_name"])
@testing.only_on("sqlite", "sqlite specific feature")
def test_column_accessor_sqlite_raw(self):
@@ -784,7 +784,7 @@ class QueryTest(fixtures.TestBase):
assert 'user_name' not in r
eq_(r['query_users.user_id'], 1)
eq_(r['query_users.user_name'], "john")
- eq_(r.keys(), ["query_users.user_id", "query_users.user_name"])
+ eq_(list(r.keys()), ["query_users.user_id", "query_users.user_name"])
@testing.only_on("sqlite", "sqlite specific feature")
def test_column_accessor_sqlite_translated(self):
@@ -799,7 +799,7 @@ class QueryTest(fixtures.TestBase):
eq_(r['user_name'], "john")
eq_(r['query_users.user_id'], 1)
eq_(r['query_users.user_name'], "john")
- eq_(r.keys(), ["user_id", "user_name"])
+ eq_(list(r.keys()), ["user_id", "user_name"])
def test_column_accessor_labels_w_dots(self):
users.insert().execute(
@@ -812,7 +812,7 @@ class QueryTest(fixtures.TestBase):
eq_(r['query_users.user_id'], 1)
eq_(r['query_users.user_name'], "john")
assert "user_name" not in r
- eq_(r.keys(), ["query_users.user_id", "query_users.user_name"])
+ eq_(list(r.keys()), ["query_users.user_id", "query_users.user_name"])
def test_column_accessor_unary(self):
users.insert().execute(
@@ -889,7 +889,7 @@ class QueryTest(fixtures.TestBase):
])
).first()
- eq_(row.keys(), ["case_insensitive", "CaseSensitive"])
+ eq_(list(row.keys()), ["case_insensitive", "CaseSensitive"])
eq_(row["case_insensitive"], 1)
eq_(row["CaseSensitive"], 2)
@@ -911,7 +911,7 @@ class QueryTest(fixtures.TestBase):
])
).first()
- eq_(row.keys(), ["case_insensitive", "CaseSensitive"])
+ eq_(list(row.keys()), ["case_insensitive", "CaseSensitive"])
eq_(row["case_insensitive"], 1)
eq_(row["CaseSensitive"], 2)
eq_(row["Case_insensitive"],1)
@@ -1072,14 +1072,14 @@ class QueryTest(fixtures.TestBase):
def test_keys(self):
users.insert().execute(user_id=1, user_name='foo')
r = users.select().execute()
- eq_([x.lower() for x in r.keys()], ['user_id', 'user_name'])
+ eq_([x.lower() for x in list(r.keys())], ['user_id', 'user_name'])
r = r.first()
- eq_([x.lower() for x in r.keys()], ['user_id', 'user_name'])
+ eq_([x.lower() for x in list(r.keys())], ['user_id', 'user_name'])
def test_items(self):
users.insert().execute(user_id=1, user_name='foo')
r = users.select().execute().first()
- eq_([(x[0].lower(), x[1]) for x in r.items()], [('user_id', 1), ('user_name', 'foo')])
+ eq_([(x[0].lower(), x[1]) for x in list(r.items())], [('user_id', 1), ('user_name', 'foo')])
def test_len(self):
users.insert().execute(user_id=1, user_name='foo')
@@ -1098,8 +1098,8 @@ class QueryTest(fixtures.TestBase):
r = users.select(users.c.user_id==1).execute().first()
eq_(r[0], 1)
eq_(r[1], 'foo')
- eq_([x.lower() for x in r.keys()], ['user_id', 'user_name'])
- eq_(r.values(), [1, 'foo'])
+ eq_([x.lower() for x in list(r.keys())], ['user_id', 'user_name'])
+ eq_(list(r.values()), [1, 'foo'])
def test_column_order_with_text_query(self):
# should return values in query order
@@ -1107,8 +1107,8 @@ class QueryTest(fixtures.TestBase):
r = testing.db.execute('select user_name, user_id from query_users').first()
eq_(r[0], 'foo')
eq_(r[1], 1)
- eq_([x.lower() for x in r.keys()], ['user_name', 'user_id'])
- eq_(r.values(), ['foo', 1])
+ eq_([x.lower() for x in list(r.keys())], ['user_name', 'user_id'])
+ eq_(list(r.values()), ['foo', 1])
@testing.crashes('oracle', 'FIXME: unknown, varify not fails_on()')
@testing.crashes('firebird', 'An identifier must begin with a letter')
@@ -1137,7 +1137,7 @@ class QueryTest(fixtures.TestBase):
self.assert_(r['_parent'] == 'Hidden parent')
self.assert_(r['_row'] == 'Hidden row')
try:
- print r._parent, r._row
+ print(r._parent, r._row)
self.fail('Should not allow access to private attributes')
except AttributeError:
pass # expected
@@ -2334,7 +2334,7 @@ class JoinTest(fixtures.TestBase):
expr = select(
[t1.c.t1_id, t2.c.t2_id, t3.c.t3_id],
from_obj=[(t1.join(t2).outerjoin(t3, criteria))])
- print expr
+ print(expr)
self.assertRows(expr, [(10, 20, 30), (11, 21, None)])
def test_mixed_where(self):
@@ -2416,7 +2416,7 @@ class OperatorTest(fixtures.TestBase):
select([
flds.c.intcol, func.row_number().over(order_by=flds.c.strcol)
]).execute().fetchall(),
- [(13, 1L), (5, 2L)]
+ [(13, 1), (5, 2)]
)
diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py
index 8b14d23a9..717f0f797 100644
--- a/test/sql/test_quote.py
+++ b/test/sql/test_quote.py
@@ -552,8 +552,8 @@ class PreparerTest(fixtures.TestBase):
def a_eq(have, want):
if have != want:
- print "Wanted %s" % want
- print "Received %s" % have
+ print("Wanted %s" % want)
+ print("Received %s" % have)
self.assert_(have == want)
a_eq(unformat('foo'), ['foo'])
@@ -584,13 +584,13 @@ class PreparerTest(fixtures.TestBase):
def a_eq(have, want):
if have != want:
- print "Wanted %s" % want
- print "Received %s" % have
+ print("Wanted %s" % want)
+ print("Received %s" % have)
self.assert_(have == want)
a_eq(unformat('foo'), ['foo'])
a_eq(unformat('`foo`'), ['foo'])
- a_eq(unformat(`'foo'`), ["'foo'"])
+ a_eq(unformat(repr('foo')), ["'foo'"])
a_eq(unformat('foo.bar'), ['foo', 'bar'])
a_eq(unformat('`foo`.`bar`'), ['foo', 'bar'])
a_eq(unformat('foo.`bar`'), ['foo', 'bar'])
diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py
index f14f78989..2dbf4f3ea 100644
--- a/test/sql/test_rowcount.py
+++ b/test/sql/test_rowcount.py
@@ -53,20 +53,20 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults):
# WHERE matches 3, 3 rows changed
department = employees_table.c.department
r = employees_table.update(department=='C').execute(department='Z')
- print "expecting 3, dialect reports %s" % r.rowcount
+ print("expecting 3, dialect reports %s" % r.rowcount)
assert r.rowcount == 3
def test_update_rowcount2(self):
# WHERE matches 3, 0 rows changed
department = employees_table.c.department
r = employees_table.update(department=='C').execute(department='C')
- print "expecting 3, dialect reports %s" % r.rowcount
+ print("expecting 3, dialect reports %s" % r.rowcount)
assert r.rowcount == 3
def test_delete_rowcount(self):
# WHERE matches 3, 3 rows deleted
department = employees_table.c.department
r = employees_table.delete(department=='C').execute()
- print "expecting 3, dialect reports %s" % r.rowcount
+ print("expecting 3, dialect reports %s" % r.rowcount)
assert r.rowcount == 3
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index e881298a7..e697a7e08 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -174,11 +174,11 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
def test_clone_append_column(self):
sel = select([literal_column('1').label('a')])
- eq_(sel.c.keys(), ['a'])
+ eq_(list(sel.c.keys()), ['a'])
cloned = visitors.ReplacingCloningVisitor().traverse(sel)
cloned.append_column(literal_column('2').label('b'))
cloned.append_column(func.foo())
- eq_(cloned.c.keys(), ['a', 'b', 'foo()'])
+ eq_(list(cloned.c.keys()), ['a', 'b', 'foo()'])
def test_append_column_after_replace_selectable(self):
basesel = select([literal_column('1').label('a')])
@@ -362,10 +362,10 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
def test_join(self):
a = join(table1, table2)
- print str(a.select(use_labels=True))
+ print(str(a.select(use_labels=True)))
b = table2.alias('b')
j = join(a, b)
- print str(j)
+ print(str(j))
criterion = a.c.table1_col1 == b.c.col2
self.assert_(criterion.compare(j.onclause))
@@ -949,7 +949,7 @@ class PrimaryKeyTest(fixtures.TestBase, AssertsExecutionResults):
primary_key=True), Column('x', Integer))
d = Table('d', meta, Column('id', Integer, ForeignKey('c.id'),
primary_key=True), Column('x', Integer))
- print list(a.join(b, a.c.x == b.c.id).primary_key)
+ print(list(a.join(b, a.c.x == b.c.id).primary_key))
assert list(a.join(b, a.c.x == b.c.id).primary_key) == [a.c.id]
assert list(b.join(c, b.c.x == c.c.id).primary_key) == [b.c.id]
assert list(a.join(b).join(c, c.c.id == b.c.x).primary_key) \
@@ -1618,7 +1618,7 @@ class WithLabelsTest(fixtures.TestBase):
def test_names_overlap_label(self):
sel = self._names_overlap().apply_labels()
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['t1_x', 't2_x']
)
self._assert_result_keys(sel, ['t1_x', 't2_x'])
@@ -1632,7 +1632,7 @@ class WithLabelsTest(fixtures.TestBase):
def test_names_overlap_keys_dont_nolabel(self):
sel = self._names_overlap_keys_dont()
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['a', 'b']
)
self._assert_result_keys(sel, ['x'])
@@ -1640,7 +1640,7 @@ class WithLabelsTest(fixtures.TestBase):
def test_names_overlap_keys_dont_label(self):
sel = self._names_overlap_keys_dont().apply_labels()
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['t1_a', 't2_b']
)
self._assert_result_keys(sel, ['t1_x', 't2_x'])
@@ -1654,7 +1654,7 @@ class WithLabelsTest(fixtures.TestBase):
def test_labels_overlap_nolabel(self):
sel = self._labels_overlap()
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['x_id', 'id']
)
self._assert_result_keys(sel, ['x_id', 'id'])
@@ -1663,7 +1663,7 @@ class WithLabelsTest(fixtures.TestBase):
sel = self._labels_overlap().apply_labels()
t2 = sel.froms[1]
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['t_x_id', t2.c.id.anon_label]
)
self._assert_result_keys(sel, ['t_x_id', 'id_1'])
@@ -1677,12 +1677,12 @@ class WithLabelsTest(fixtures.TestBase):
def test_labels_overlap_keylabels_dont_nolabel(self):
sel = self._labels_overlap_keylabels_dont()
- eq_(sel.c.keys(), ['a', 'b'])
+ eq_(list(sel.c.keys()), ['a', 'b'])
self._assert_result_keys(sel, ['x_id', 'id'])
def test_labels_overlap_keylabels_dont_label(self):
sel = self._labels_overlap_keylabels_dont().apply_labels()
- eq_(sel.c.keys(), ['t_a', 't_x_b'])
+ eq_(list(sel.c.keys()), ['t_a', 't_x_b'])
self._assert_result_keys(sel, ['t_x_id', 'id_1'])
def _keylabels_overlap_labels_dont(self):
@@ -1693,13 +1693,13 @@ class WithLabelsTest(fixtures.TestBase):
def test_keylabels_overlap_labels_dont_nolabel(self):
sel = self._keylabels_overlap_labels_dont()
- eq_(sel.c.keys(), ['x_id', 'id'])
+ eq_(list(sel.c.keys()), ['x_id', 'id'])
self._assert_result_keys(sel, ['a', 'b'])
def test_keylabels_overlap_labels_dont_label(self):
sel = self._keylabels_overlap_labels_dont().apply_labels()
t2 = sel.froms[1]
- eq_(sel.c.keys(), ['t_x_id', t2.c.id.anon_label])
+ eq_(list(sel.c.keys()), ['t_x_id', t2.c.id.anon_label])
self._assert_result_keys(sel, ['t_a', 't_x_b'])
self._assert_subq_result_keys(sel, ['t_a', 't_x_b'])
@@ -1711,14 +1711,14 @@ class WithLabelsTest(fixtures.TestBase):
def test_keylabels_overlap_labels_overlap_nolabel(self):
sel = self._keylabels_overlap_labels_overlap()
- eq_(sel.c.keys(), ['x_a', 'a'])
+ eq_(list(sel.c.keys()), ['x_a', 'a'])
self._assert_result_keys(sel, ['x_id', 'id'])
self._assert_subq_result_keys(sel, ['x_id', 'id'])
def test_keylabels_overlap_labels_overlap_label(self):
sel = self._keylabels_overlap_labels_overlap().apply_labels()
t2 = sel.froms[1]
- eq_(sel.c.keys(), ['t_x_a', t2.c.a.anon_label])
+ eq_(list(sel.c.keys()), ['t_x_a', t2.c.a.anon_label])
self._assert_result_keys(sel, ['t_x_id', 'id_1'])
self._assert_subq_result_keys(sel, ['t_x_id', 'id_1'])
@@ -1736,7 +1736,7 @@ class WithLabelsTest(fixtures.TestBase):
def test_keys_overlap_names_dont_label(self):
sel = self._keys_overlap_names_dont().apply_labels()
eq_(
- sel.c.keys(),
+ list(sel.c.keys()),
['t1_x', 't2_x']
)
self._assert_result_keys(sel, ['t1_a', 't2_b'])
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index 407869f15..f44ee9286 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -141,22 +141,24 @@ class AdaptTest(fixtures.TestBase):
eq_(types.Integer().python_type, int)
eq_(types.Numeric().python_type, decimal.Decimal)
eq_(types.Numeric(asdecimal=False).python_type, float)
- # Py3K
- #eq_(types.LargeBinary().python_type, bytes)
- # Py2K
- eq_(types.LargeBinary().python_type, str)
- # end Py2K
+# start Py3K
+ eq_(types.LargeBinary().python_type, bytes)
+# end Py3K
+# start Py2K
+# eq_(types.LargeBinary().python_type, str)
+# end Py2K
eq_(types.Float().python_type, float)
eq_(types.Interval().python_type, datetime.timedelta)
eq_(types.Date().python_type, datetime.date)
eq_(types.DateTime().python_type, datetime.datetime)
- # Py3K
- #eq_(types.String().python_type, unicode)
- # Py2K
+# start Py3K
eq_(types.String().python_type, str)
- # end Py2K
- eq_(types.Unicode().python_type, unicode)
- eq_(types.String(convert_unicode=True).python_type, unicode)
+# end Py3K
+# start Py2K
+# eq_(types.String().python_type, str)
+# end Py2K
+ eq_(types.Unicode().python_type, str)
+ eq_(types.String(convert_unicode=True).python_type, str)
assert_raises(
NotImplementedError,
@@ -257,14 +259,14 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
def test_processing(self):
users = self.tables.users
users.insert().execute(
- user_id=2, goofy='jack', goofy2='jack', goofy4=u'jack',
- goofy7=u'jack', goofy8=12, goofy9=12)
+ user_id=2, goofy='jack', goofy2='jack', goofy4='jack',
+ goofy7='jack', goofy8=12, goofy9=12)
users.insert().execute(
- user_id=3, goofy='lala', goofy2='lala', goofy4=u'lala',
- goofy7=u'lala', goofy8=15, goofy9=15)
+ user_id=3, goofy='lala', goofy2='lala', goofy4='lala',
+ goofy7='lala', goofy8=15, goofy9=15)
users.insert().execute(
- user_id=4, goofy='fred', goofy2='fred', goofy4=u'fred',
- goofy7=u'fred', goofy8=9, goofy9=9)
+ user_id=4, goofy='fred', goofy2='fred', goofy4='fred',
+ goofy7='fred', goofy8=9, goofy9=9)
l = users.select().order_by(users.c.user_id).execute().fetchall()
for assertstr, assertint, assertint2, row in zip(
@@ -278,7 +280,7 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
eq_(row[5], assertint)
eq_(row[6], assertint2)
for col in row[3], row[4]:
- assert isinstance(col, unicode)
+ assert isinstance(col, str)
def test_typedecorator_impl(self):
for impl_, exp, kw in [
@@ -715,9 +717,9 @@ class UnicodeTest(fixtures.TestBase):
expected
)
- data = u"Alors vous imaginez ma surprise, au lever du jour, quand "\
- u"une drôle de petite voix m’a réveillé. "\
- u"Elle disait: « S’il vous plaît… dessine-moi un mouton! »"
+ data = "Alors vous imaginez ma surprise, au lever du jour, quand "\
+ "une drôle de petite voix m’a réveillé. "\
+ "Elle disait: « S’il vous plaît… dessine-moi un mouton! »"
def test_unicode_warnings_typelevel_native_unicode(self):
@@ -726,13 +728,14 @@ class UnicodeTest(fixtures.TestBase):
dialect = default.DefaultDialect()
dialect.supports_unicode_binds = True
uni = u.dialect_impl(dialect).bind_processor(dialect)
- # Py3K
- #assert_raises(exc.SAWarning, uni, b'x')
- #assert isinstance(uni(unicodedata), str)
- # Py2K
- assert_raises(exc.SAWarning, uni, 'x')
- assert isinstance(uni(unicodedata), unicode)
- # end Py2K
+# start Py3K
+ assert_raises(exc.SAWarning, uni, b'x')
+ assert isinstance(uni(unicodedata), str)
+# end Py3K
+# start Py2K
+# assert_raises(exc.SAWarning, uni, 'x')
+# assert isinstance(uni(unicodedata), unicode)
+# end Py2K
def test_unicode_warnings_typelevel_sqla_unicode(self):
unicodedata = self.data
@@ -740,13 +743,14 @@ class UnicodeTest(fixtures.TestBase):
dialect = default.DefaultDialect()
dialect.supports_unicode_binds = False
uni = u.dialect_impl(dialect).bind_processor(dialect)
- # Py3K
- #assert_raises(exc.SAWarning, uni, b'x')
- #assert isinstance(uni(unicodedata), bytes)
- # Py2K
- assert_raises(exc.SAWarning, uni, 'x')
- assert isinstance(uni(unicodedata), str)
- # end Py2K
+# start Py3K
+ assert_raises(exc.SAWarning, uni, b'x')
+ assert isinstance(uni(unicodedata), bytes)
+# end Py3K
+# start Py2K
+# assert_raises(exc.SAWarning, uni, 'x')
+# assert isinstance(uni(unicodedata), str)
+# end Py2K
eq_(uni(unicodedata), unicodedata.encode('utf-8'))
@@ -760,13 +764,14 @@ class UnicodeTest(fixtures.TestBase):
s = String()
uni = s.dialect_impl(dialect).bind_processor(dialect)
# this is not the unicode type - no warning
- # Py3K
- #uni(b'x')
- #assert isinstance(uni(unicodedata), bytes)
- # Py2K
- uni('x')
- assert isinstance(uni(unicodedata), str)
- # end Py2K
+# start Py3K
+ uni(b'x')
+ assert isinstance(uni(unicodedata), bytes)
+# end Py3K
+# start Py2K
+# uni('x')
+# assert isinstance(uni(unicodedata), str)
+# end Py2K
eq_(uni(unicodedata), unicodedata.encode('utf-8'))
@@ -1366,7 +1371,7 @@ class NumericRawSQLTest(fixtures.TestBase):
metadata = self.metadata
t = self._fixture(metadata, Integer, 45)
val = testing.db.execute("select val from t").scalar()
- assert isinstance(val, (int, long))
+ assert isinstance(val, int)
eq_(val, 45)
@testing.provide_metadata
diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py
index 37e44522e..2ab081dad 100644
--- a/test/sql/test_unicode.py
+++ b/test/sql/test_unicode.py
@@ -19,13 +19,13 @@ class UnicodeSchemaTest(fixtures.TestBase):
metadata = MetaData(unicode_bind)
t1 = Table('unitable1', metadata,
- Column(u'méil', Integer, primary_key=True),
- Column(u'\u6e2c\u8a66', Integer),
+ Column('méil', Integer, primary_key=True),
+ Column('\u6e2c\u8a66', Integer),
test_needs_fk=True,
)
- t2 = Table(u'Unitéble2', metadata,
- Column(u'méil', Integer, primary_key=True, key="a"),
- Column(u'\u6e2c\u8a66', Integer, ForeignKey(u'unitable1.méil'),
+ t2 = Table('Unitéble2', metadata,
+ Column('méil', Integer, primary_key=True, key="a"),
+ Column('\u6e2c\u8a66', Integer, ForeignKey('unitable1.méil'),
key="b"
),
test_needs_fk=True,
@@ -33,27 +33,27 @@ class UnicodeSchemaTest(fixtures.TestBase):
# Few DBs support Unicode foreign keys
if testing.against('sqlite'):
- t3 = Table(u'\u6e2c\u8a66', metadata,
- Column(u'\u6e2c\u8a66_id', Integer, primary_key=True,
+ t3 = Table('\u6e2c\u8a66', metadata,
+ Column('\u6e2c\u8a66_id', Integer, primary_key=True,
autoincrement=False),
- Column(u'unitable1_\u6e2c\u8a66', Integer,
- ForeignKey(u'unitable1.\u6e2c\u8a66')
+ Column('unitable1_\u6e2c\u8a66', Integer,
+ ForeignKey('unitable1.\u6e2c\u8a66')
),
- Column(u'Unitéble2_b', Integer,
- ForeignKey(u'Unitéble2.b')
+ Column('Unitéble2_b', Integer,
+ ForeignKey('Unitéble2.b')
),
- Column(u'\u6e2c\u8a66_self', Integer,
- ForeignKey(u'\u6e2c\u8a66.\u6e2c\u8a66_id')
+ Column('\u6e2c\u8a66_self', Integer,
+ ForeignKey('\u6e2c\u8a66.\u6e2c\u8a66_id')
),
test_needs_fk=True,
)
else:
- t3 = Table(u'\u6e2c\u8a66', metadata,
- Column(u'\u6e2c\u8a66_id', Integer, primary_key=True,
+ t3 = Table('\u6e2c\u8a66', metadata,
+ Column('\u6e2c\u8a66_id', Integer, primary_key=True,
autoincrement=False),
- Column(u'unitable1_\u6e2c\u8a66', Integer),
- Column(u'Unitéble2_b', Integer),
- Column(u'\u6e2c\u8a66_self', Integer),
+ Column('unitable1_\u6e2c\u8a66', Integer),
+ Column('Unitéble2_b', Integer),
+ Column('\u6e2c\u8a66_self', Integer),
test_needs_fk=True,
)
metadata.create_all()
@@ -72,42 +72,42 @@ class UnicodeSchemaTest(fixtures.TestBase):
del unicode_bind
def test_insert(self):
- t1.insert().execute({u'méil':1, u'\u6e2c\u8a66':5})
+ t1.insert().execute({'méil':1, '\u6e2c\u8a66':5})
t2.insert().execute({'a':1, 'b':1})
- t3.insert().execute({u'\u6e2c\u8a66_id': 1,
- u'unitable1_\u6e2c\u8a66': 5,
- u'Unitéble2_b': 1,
- u'\u6e2c\u8a66_self': 1})
+ t3.insert().execute({'\u6e2c\u8a66_id': 1,
+ 'unitable1_\u6e2c\u8a66': 5,
+ 'Unitéble2_b': 1,
+ '\u6e2c\u8a66_self': 1})
assert t1.select().execute().fetchall() == [(1, 5)]
assert t2.select().execute().fetchall() == [(1, 1)]
assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
def test_reflect(self):
- t1.insert().execute({u'méil':2, u'\u6e2c\u8a66':7})
+ t1.insert().execute({'méil':2, '\u6e2c\u8a66':7})
t2.insert().execute({'a':2, 'b':2})
- t3.insert().execute({u'\u6e2c\u8a66_id': 2,
- u'unitable1_\u6e2c\u8a66': 7,
- u'Unitéble2_b': 2,
- u'\u6e2c\u8a66_self': 2})
+ t3.insert().execute({'\u6e2c\u8a66_id': 2,
+ 'unitable1_\u6e2c\u8a66': 7,
+ 'Unitéble2_b': 2,
+ '\u6e2c\u8a66_self': 2})
meta = MetaData(unicode_bind)
tt1 = Table(t1.name, meta, autoload=True)
tt2 = Table(t2.name, meta, autoload=True)
tt3 = Table(t3.name, meta, autoload=True)
- tt1.insert().execute({u'méil':1, u'\u6e2c\u8a66':5})
- tt2.insert().execute({u'méil':1, u'\u6e2c\u8a66':1})
- tt3.insert().execute({u'\u6e2c\u8a66_id': 1,
- u'unitable1_\u6e2c\u8a66': 5,
- u'Unitéble2_b': 1,
- u'\u6e2c\u8a66_self': 1})
+ tt1.insert().execute({'méil':1, '\u6e2c\u8a66':5})
+ tt2.insert().execute({'méil':1, '\u6e2c\u8a66':1})
+ tt3.insert().execute({'\u6e2c\u8a66_id': 1,
+ 'unitable1_\u6e2c\u8a66': 5,
+ 'Unitéble2_b': 1,
+ '\u6e2c\u8a66_self': 1})
- self.assert_(tt1.select(order_by=desc(u'méil')).execute().fetchall() ==
+ self.assert_(tt1.select(order_by=desc('méil')).execute().fetchall() ==
[(2, 7), (1, 5)])
- self.assert_(tt2.select(order_by=desc(u'méil')).execute().fetchall() ==
+ self.assert_(tt2.select(order_by=desc('méil')).execute().fetchall() ==
[(2, 2), (1, 1)])
- self.assert_(tt3.select(order_by=desc(u'\u6e2c\u8a66_id')).
+ self.assert_(tt3.select(order_by=desc('\u6e2c\u8a66_id')).
execute().fetchall() ==
[(2, 7, 2, 2), (1, 5, 1, 1)])
meta.drop_all()
@@ -117,7 +117,7 @@ class EscapesDefaultsTest(fixtures.TestBase):
def test_default_exec(self):
metadata = MetaData(testing.db)
t1 = Table('t1', metadata,
- Column(u'special_col', Integer, Sequence('special_col'), primary_key=True),
+ Column('special_col', Integer, Sequence('special_col'), primary_key=True),
Column('data', String(50)) # to appease SQLite without DEFAULT VALUES
)
metadata.create_all()
@@ -128,8 +128,8 @@ class EscapesDefaultsTest(fixtures.TestBase):
# reset the identifier preparer, so that we can force it to cache
# a unicode identifier
engine.dialect.identifier_preparer = engine.dialect.preparer(engine.dialect)
- select([column(u'special_col')]).select_from(t1).execute().close()
- assert isinstance(engine.dialect.identifier_preparer.format_sequence(Sequence('special_col')), unicode)
+ select([column('special_col')]).select_from(t1).execute().close()
+ assert isinstance(engine.dialect.identifier_preparer.format_sequence(Sequence('special_col')), str)
# now execute, run the sequence. it should run in u"Special_col.nextid" or similar as
# a unicode object; cx_oracle asserts that this is None or a String (postgresql lets it pass thru).
diff --git a/test/sql/test_update.py b/test/sql/test_update.py
index a8df86cd2..8695760fb 100644
--- a/test/sql/test_update.py
+++ b/test/sql/test_update.py
@@ -242,7 +242,7 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest,
'WHERE '
'users.id = addresses.user_id AND '
'addresses.email_address = :email_address_1',
- checkparams={u'email_address_1': 'e1', 'name': 'newname'})
+ checkparams={'email_address_1': 'e1', 'name': 'newname'})
def test_render_multi_table(self):
users = self.tables.users
@@ -250,8 +250,8 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest,
dingalings = self.tables.dingalings
checkparams = {
- u'email_address_1': 'e1',
- u'id_1': 2,
+ 'email_address_1': 'e1',
+ 'id_1': 2,
'name': 'newname'
}
@@ -285,15 +285,15 @@ class UpdateFromCompileTest(_UpdateFromTestBase, fixtures.TablesTest,
'WHERE '
'users.id = addresses.user_id AND '
'addresses.email_address = %s',
- checkparams={u'email_address_1': 'e1', 'name': 'newname'},
+ checkparams={'email_address_1': 'e1', 'name': 'newname'},
dialect=mysql.dialect())
def test_render_subquery(self):
users, addresses = self.tables.users, self.tables.addresses
checkparams = {
- u'email_address_1': 'e1',
- u'id_1': 7,
+ 'email_address_1': 'e1',
+ 'id_1': 7,
'name': 'newname'
}