diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
| commit | 4b614b9b35cd2baddb7ca67c04bee5d70ec6a172 (patch) | |
| tree | 7483cd269f5823f903f96709eb864fff9b6d9383 /test/dialect | |
| parent | 9716a5c45e6185c5871555722d8495880f0e8c7a (diff) | |
| download | sqlalchemy-4b614b9b35cd2baddb7ca67c04bee5d70ec6a172.tar.gz | |
- the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
Diffstat (limited to 'test/dialect')
| -rw-r--r-- | test/dialect/test_firebird.py | 2 | ||||
| -rw-r--r-- | test/dialect/test_mssql.py | 30 | ||||
| -rw-r--r-- | test/dialect/test_mysql.py | 34 | ||||
| -rw-r--r-- | test/dialect/test_oracle.py | 32 | ||||
| -rw-r--r-- | test/dialect/test_postgresql.py | 44 | ||||
| -rw-r--r-- | test/dialect/test_sqlite.py | 10 | ||||
| -rw-r--r-- | test/dialect/test_sybase.py | 2 |
7 files changed, 77 insertions, 77 deletions
diff --git a/test/dialect/test_firebird.py b/test/dialect/test_firebird.py index 5a80a3776..6019dc8f9 100644 --- a/test/dialect/test_firebird.py +++ b/test/dialect/test_firebird.py @@ -28,7 +28,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): ) con.execute('CREATE DOMAIN img_domain AS BLOB SUB_TYPE ' 'BINARY') - except ProgrammingError, e: + except ProgrammingError as e: if not 'attempt to store duplicate value' in str(e): raise e con.execute('''CREATE GENERATOR gen_testtable_id''') diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index f1cd3fe85..cca06f1cc 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -403,7 +403,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( s, "SELECT TOP 10 t.x, t.y FROM t WHERE t.x = :x_1 ORDER BY t.y", - checkparams={u'x_1': 5} + checkparams={'x_1': 5} ) def test_limit_zero_using_top(self): @@ -414,7 +414,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( s, "SELECT TOP 0 t.x, t.y FROM t WHERE t.x = :x_1 ORDER BY t.y", - checkparams={u'x_1': 5} + checkparams={'x_1': 5} ) def test_offset_using_window(self): @@ -424,14 +424,14 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): # test that the select is not altered with subsequent compile # calls - for i in xrange(2): + for i in range(2): self.assert_compile( s, "SELECT anon_1.x, anon_1.y FROM (SELECT t.x AS x, t.y " "AS y, ROW_NUMBER() OVER (ORDER BY t.y) AS " "mssql_rn FROM t WHERE t.x = :x_1) AS " "anon_1 WHERE mssql_rn > :mssql_rn_1", - checkparams={u'mssql_rn_1': 20, u'x_1': 5} + checkparams={'mssql_rn_1': 20, 'x_1': 5} ) def test_limit_offset_using_window(self): @@ -447,7 +447,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "FROM t " "WHERE t.x = :x_1) AS anon_1 " "WHERE mssql_rn > :mssql_rn_1 AND mssql_rn <= :mssql_rn_2", - checkparams={u'mssql_rn_1': 20, u'mssql_rn_2': 30, u'x_1': 5} + checkparams={'mssql_rn_1': 20, 'mssql_rn_2': 30, 'x_1': 5} ) def test_limit_offset_with_correlated_order_by(self): @@ -468,7 +468,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "FROM t1 " "WHERE t1.x = :x_1) AS anon_1 " "WHERE mssql_rn > :mssql_rn_1 AND mssql_rn <= :mssql_rn_2", - checkparams={u'mssql_rn_1': 20, u'mssql_rn_2': 30, u'x_1': 5} + checkparams={'mssql_rn_1': 20, 'mssql_rn_2': 30, 'x_1': 5} ) def test_limit_zero_offset_using_window(self): @@ -482,7 +482,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): s, "SELECT TOP 0 t.x, t.y FROM t " "WHERE t.x = :x_1 ORDER BY t.y", - checkparams={u'x_1': 5} + checkparams={'x_1': 5} ) def test_sequence_start_0(self): @@ -851,11 +851,11 @@ class QueryUnicodeTest(fixtures.TestBase): # encode in UTF-8 (sting object) because this is the default # dialect encoding - con.execute(u"insert into unitest_table values ('bien u\ + con.execute("insert into unitest_table values ('bien u\ umang\xc3\xa9')".encode('UTF-8')) try: r = t1.select().execute().first() - assert isinstance(r[1], unicode), \ + assert isinstance(r[1], str), \ '%s is %s instead of unicode, working on %s' % (r[1], type(r[1]), meta.bind) finally: @@ -1707,7 +1707,7 @@ class TypeRoundTripTest(fixtures.TestBase, AssertsExecutionResults, ComparesTabl )] for value in test_items: float_table.insert().execute(floatcol=value) - except Exception, e: + except Exception as e: raise e @@ -1953,8 +1953,8 @@ class MonkeyPatchedBinaryTest(fixtures.TestBase): def test_unicode(self): module = __import__('pymssql') - result = module.Binary(u'foo') - eq_(result, u'foo') + result = module.Binary('foo') + eq_(result, 'foo') def test_bytes(self): module = __import__('pymssql') @@ -2073,7 +2073,7 @@ class InfoCoerceUnicodeTest(fixtures.TestBase): dialect = mssql.dialect() value = CoerceUnicode().bind_processor(dialect)('a string') - assert isinstance(value, unicode) + assert isinstance(value, str) class ReflectHugeViewTest(fixtures.TestBase): __only_on__ = 'mssql' @@ -2085,13 +2085,13 @@ class ReflectHugeViewTest(fixtures.TestBase): t = Table('base_table', self.metadata, *[ Column("long_named_column_number_%d" % i, Integer) - for i in xrange(self.col_num) + for i in range(self.col_num) ] ) self.view_str = view_str = \ "CREATE VIEW huge_named_view AS SELECT %s FROM base_table" % ( ",".join("long_named_column_number_%d" % i - for i in xrange(self.col_num)) + for i in range(self.col_num)) ) assert len(view_str) > 4000 diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py index f89b0b229..df4eab86a 100644 --- a/test/dialect/test_mysql.py +++ b/test/dialect/test_mysql.py @@ -372,9 +372,9 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): try: self.assert_(list(row) == expected) except: - print "Storing %s" % store - print "Expected %s" % expected - print "Found %s" % list(row) + print("Storing %s" % store) + print("Expected %s" % expected) + print("Found %s" % list(row)) raise table.delete().execute().close() @@ -684,17 +684,17 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): metadata = MetaData(unicode_engine) t1 = Table('table', metadata, Column('id', Integer, primary_key=True), - Column('value', Enum(u'réveillé', u'drôle', u'S’il')), - Column('value2', mysql.ENUM(u'réveillé', u'drôle', u'S’il')) + Column('value', Enum('réveillé', 'drôle', 'S’il')), + Column('value2', mysql.ENUM('réveillé', 'drôle', 'S’il')) ) metadata.create_all() try: - t1.insert().execute(value=u'drôle', value2=u'drôle') - t1.insert().execute(value=u'réveillé', value2=u'réveillé') - t1.insert().execute(value=u'S’il', value2=u'S’il') + t1.insert().execute(value='drôle', value2='drôle') + t1.insert().execute(value='réveillé', value2='réveillé') + t1.insert().execute(value='S’il', value2='S’il') eq_(t1.select().order_by(t1.c.id).execute().fetchall(), - [(1, u'drôle', u'drôle'), (2, u'réveillé', u'réveillé'), - (3, u'S’il', u'S’il')] + [(1, 'drôle', 'drôle'), (2, 'réveillé', 'réveillé'), + (3, 'S’il', 'S’il')] ) # test reflection of the enum labels @@ -706,10 +706,10 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): # latin-1 stuff forcing its way in ? assert t2.c.value.type.enums[0:2] == \ - (u'réveillé', u'drôle') # u'S’il') # eh ? + ('réveillé', 'drôle') # u'S’il') # eh ? assert t2.c.value2.type.enums[0:2] == \ - (u'réveillé', u'drôle') # u'S’il') # eh ? + ('réveillé', 'drôle') # u'S’il') # eh ? finally: metadata.drop_all() @@ -877,13 +877,13 @@ class ReflectionTest(fixtures.TestBase, AssertsExecutionResults): reflected = Table('mysql_case', MetaData(testing.db), autoload=True, include_columns=['c1', 'C2']) for t in case_table, reflected: - assert 'c1' in t.c.keys() - assert 'C2' in t.c.keys() + assert 'c1' in list(t.c.keys()) + assert 'C2' in list(t.c.keys()) reflected2 = Table('mysql_case', MetaData(testing.db), autoload=True, include_columns=['c1', 'c2']) - assert 'c1' in reflected2.c.keys() + assert 'c1' in list(reflected2.c.keys()) for c in ['c2', 'C2', 'C3']: - assert c not in reflected2.c.keys() + assert c not in list(reflected2.c.keys()) finally: case_table.drop() @@ -1370,7 +1370,7 @@ class SQLModeDetectionTest(fixtures.TestBase): def _options(self, modes): def connect(con, record): cursor = con.cursor() - print "DOING THiS:", "set sql_mode='%s'" % (",".join(modes)) + print("DOING THiS:", "set sql_mode='%s'" % (",".join(modes))) cursor.execute("set sql_mode='%s'" % (",".join(modes))) e = engines.testing_engine(options={ 'pool_events':[ diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index 861b28c5f..fd86d4ff9 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -1,5 +1,5 @@ # coding: utf-8 -from __future__ import with_statement + from sqlalchemy.testing import eq_ from sqlalchemy import * @@ -807,7 +807,7 @@ class TwoPhaseTest(fixtures.TablesTest): ) def test_twophase_prepare_false(self): conn = self._connection() - for i in xrange(2): + for i in range(2): trans = conn.begin_twophase() conn.execute("select 1 from dual") trans.prepare() @@ -817,7 +817,7 @@ class TwoPhaseTest(fixtures.TablesTest): def test_twophase_prepare_true(self): conn = self._connection() - for i in xrange(2): + for i in range(2): trans = conn.begin_twophase() conn.execute("insert into datatable (id, data) " "values (%s, 'somedata')" % i) @@ -870,7 +870,7 @@ class DialectTypesTest(fixtures.TestBase, AssertsCompiledSQL): b = bindparam("foo", "hello world!") assert b.type.dialect_impl(dialect).get_dbapi_type(dbapi) == 'STRING' - b = bindparam("foo", u"hello world!") + b = bindparam("foo", "hello world!") assert b.type.dialect_impl(dialect).get_dbapi_type(dbapi) == 'STRING' def test_long(self): @@ -1257,7 +1257,7 @@ class TypesTest(fixtures.TestBase): autoload=True, oracle_resolve_synonyms=True ) for row in types_table.select().execute().fetchall(): - [row[k] for k in row.keys()] + [row[k] for k in list(row.keys())] @testing.provide_metadata def test_raw_roundtrip(self): @@ -1291,11 +1291,11 @@ class TypesTest(fixtures.TestBase): t2.c.data.type.dialect_impl(testing.db.dialect), cx_oracle._OracleNVarChar) - data = u'm’a réveillé.' + data = 'm’a réveillé.' t2.insert().execute(data=data) res = t2.select().execute().first()['data'] eq_(res, data) - assert isinstance(res, unicode) + assert isinstance(res, str) def test_char_length(self): @@ -1426,7 +1426,7 @@ class DontReflectIOTTest(fixtures.TestBase): m = MetaData(testing.db) m.reflect() eq_( - set(t.name for t in m.tables.values()), + set(t.name for t in list(m.tables.values())), set(['admin_docindex']) ) @@ -1641,28 +1641,28 @@ class UnicodeSchemaTest(fixtures.TestBase): metadata.create_all() table.insert().execute( - {'_underscorecolumn': u'’é'}, + {'_underscorecolumn': '’é'}, ) result = testing.db.execute( - table.select().where(table.c._underscorecolumn==u'’é') + table.select().where(table.c._underscorecolumn=='’é') ).scalar() - eq_(result, u'’é') + eq_(result, '’é') @testing.provide_metadata def test_quoted_column_unicode(self): metadata = self.metadata table=Table("atable", metadata, - Column(u"méil", Unicode(255), primary_key=True), + Column("méil", Unicode(255), primary_key=True), ) metadata.create_all() table.insert().execute( - {u'méil': u'’é'}, + {'méil': '’é'}, ) result = testing.db.execute( - table.select().where(table.c[u'méil']==u'’é') + table.select().where(table.c['méil']=='’é') ).scalar() - eq_(result, u'’é') + eq_(result, '’é') class DBLinkReflectionTest(fixtures.TestBase): @@ -1702,5 +1702,5 @@ class DBLinkReflectionTest(fixtures.TestBase): t = Table('test_table_syn', m, autoload=True, autoload_with=testing.db, oracle_resolve_synonyms=True) - eq_(t.c.keys(), ['id', 'data']) + eq_(list(t.c.keys()), ['id', 'data']) eq_(list(t.primary_key), [t.c.id]) diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index e217eb0b8..43ac7d7ae 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -1,6 +1,6 @@ # coding: utf-8 -from __future__ import with_statement + from sqlalchemy.testing.assertions import eq_, assert_raises, \ assert_raises_message, is_, AssertsExecutionResults, \ @@ -559,21 +559,21 @@ class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): t1 = Table('table', metadata, Column('id', Integer, primary_key=True), Column('value', - Enum(u'réveillé', u'drôle', u'S’il', + Enum('réveillé', 'drôle', 'S’il', name='onetwothreetype')) ) metadata.create_all() try: - t1.insert().execute(value=u'drôle') - t1.insert().execute(value=u'réveillé') - t1.insert().execute(value=u'S’il') + t1.insert().execute(value='drôle') + t1.insert().execute(value='réveillé') + t1.insert().execute(value='S’il') eq_(t1.select().order_by(t1.c.id).execute().fetchall(), - [(1, u'drôle'), (2, u'réveillé'), (3, u'S’il')] + [(1, 'drôle'), (2, 'réveillé'), (3, 'S’il')] ) m2 = MetaData(testing.db) t2 = Table('table', m2, autoload=True) - assert t2.c.value.type.enums == (u'réveillé', u'drôle', u'S’il') + assert t2.c.value.type.enums == ('réveillé', 'drôle', 'S’il') finally: metadata.drop_all() @@ -1238,7 +1238,7 @@ class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): : try: con.execute(ddl) - except exc.DBAPIError, e: + except exc.DBAPIError as e: if not 'already exists' in str(e): raise e con.execute('CREATE TABLE testtable (question integer, answer ' @@ -1476,7 +1476,7 @@ class ReflectionTest(fixtures.TestBase): meta1.create_all() meta2 = MetaData(testing.db) subject = Table('subject', meta2, autoload=True) - eq_(subject.primary_key.columns.keys(), [u'p2', u'p1']) + eq_(list(subject.primary_key.columns.keys()), ['p2', 'p1']) @testing.provide_metadata def test_pg_weirdchar_reflection(self): @@ -1749,7 +1749,7 @@ class ReflectionTest(fixtures.TestBase): conn.execute("ALTER TABLE t RENAME COLUMN x to y") ind = testing.db.dialect.get_indexes(conn, "t", None) - eq_(ind, [{'unique': False, 'column_names': [u'y'], 'name': u'idx1'}]) + eq_(ind, [{'unique': False, 'column_names': ['y'], 'name': 'idx1'}]) conn.close() class CustomTypeReflectionTest(fixtures.TestBase): @@ -2174,8 +2174,8 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults): def test_insert_array(self): arrtable = self.tables.arrtable - arrtable.insert().execute(intarr=[1, 2, 3], strarr=[u'abc', - u'def']) + arrtable.insert().execute(intarr=[1, 2, 3], strarr=['abc', + 'def']) results = arrtable.select().execute().fetchall() eq_(len(results), 1) eq_(results[0]['intarr'], [1, 2, 3]) @@ -2183,9 +2183,9 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults): def test_array_where(self): arrtable = self.tables.arrtable - arrtable.insert().execute(intarr=[1, 2, 3], strarr=[u'abc', - u'def']) - arrtable.insert().execute(intarr=[4, 5, 6], strarr=u'ABC') + arrtable.insert().execute(intarr=[1, 2, 3], strarr=['abc', + 'def']) + arrtable.insert().execute(intarr=[4, 5, 6], strarr='ABC') results = arrtable.select().where(arrtable.c.intarr == [1, 2, 3]).execute().fetchall() eq_(len(results), 1) @@ -2194,7 +2194,7 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults): def test_array_concat(self): arrtable = self.tables.arrtable arrtable.insert().execute(intarr=[1, 2, 3], - strarr=[u'abc', u'def']) + strarr=['abc', 'def']) results = select([arrtable.c.intarr + [4, 5, 6]]).execute().fetchall() eq_(len(results), 1) @@ -2203,15 +2203,15 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults): def test_array_subtype_resultprocessor(self): arrtable = self.tables.arrtable arrtable.insert().execute(intarr=[4, 5, 6], - strarr=[[u'm\xe4\xe4'], [u'm\xf6\xf6' + strarr=[['m\xe4\xe4'], ['m\xf6\xf6' ]]) - arrtable.insert().execute(intarr=[1, 2, 3], strarr=[u'm\xe4\xe4' - , u'm\xf6\xf6']) + arrtable.insert().execute(intarr=[1, 2, 3], strarr=['m\xe4\xe4' + , 'm\xf6\xf6']) results = \ arrtable.select(order_by=[arrtable.c.intarr]).execute().fetchall() eq_(len(results), 2) - eq_(results[0]['strarr'], [u'm\xe4\xe4', u'm\xf6\xf6']) - eq_(results[1]['strarr'], [[u'm\xe4\xe4'], [u'm\xf6\xf6']]) + eq_(results[0]['strarr'], ['m\xe4\xe4', 'm\xf6\xf6']) + eq_(results[1]['strarr'], [['m\xe4\xe4'], ['m\xf6\xf6']]) def test_array_literal(self): eq_( @@ -2263,7 +2263,7 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults): testing.db.execute( arrtable.insert(), intarr=[4, 5, 6], - strarr=[u'abc', u'def'] + strarr=['abc', 'def'] ) eq_( testing.db.scalar(select([arrtable.c.intarr[2:3]])), diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index 97962a54a..440fe1f43 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -84,7 +84,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): eq_(row, (1, datetime.date(2010, 5, 10), datetime.datetime( 2010, 5, 10, 12, 15, 25, ))) r = engine.execute(func.current_date()).scalar() - assert isinstance(r, basestring) + assert isinstance(r, str) finally: t.drop(engine) engine.dispose() @@ -104,8 +104,8 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): UnicodeText(), ): bindproc = t.dialect_impl(dialect).bind_processor(dialect) - assert not bindproc or isinstance(bindproc(u'some string'), - unicode) + assert not bindproc or isinstance(bindproc('some string'), + str) @testing.provide_metadata def test_type_reflection(self): @@ -566,7 +566,7 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults): eq_(inspector.get_indexes('foo'), []) eq_(inspector.get_indexes('foo', include_auto_indexes=True), [{'unique': 1, 'name' - : u'sqlite_autoindex_foo_1', 'column_names': [u'bar']}]) + : 'sqlite_autoindex_foo_1', 'column_names': ['bar']}]) finally: meta.drop_all() @@ -602,7 +602,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): 'dow': '%w', 'week': '%W', } - for field, subst in mapping.items(): + for field, subst in list(mapping.items()): self.assert_compile(select([extract(field, t.c.col1)]), "SELECT CAST(STRFTIME('%s', t.col1) AS " "INTEGER) AS anon_1 FROM t" % subst) diff --git a/test/dialect/test_sybase.py b/test/dialect/test_sybase.py index 025d49aae..1318a282b 100644 --- a/test/dialect/test_sybase.py +++ b/test/dialect/test_sybase.py @@ -19,7 +19,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'year': 'year', } - for field, subst in mapping.items(): + for field, subst in list(mapping.items()): self.assert_compile( select([extract(field, t.c.col1)]), 'SELECT DATEPART("%s", t.col1) AS anon_1 FROM t' % subst) |
