From 8f7cf2990f9010ea4924f2525318dff0ba1028d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=82=D0=B0=D0=B5=D0=B2=20=D0=94=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=81?= Date: Fri, 17 Mar 2017 14:19:21 -0400 Subject: New features from python 2.7 After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347 --- lib/sqlalchemy/testing/assertions.py | 6 +++--- lib/sqlalchemy/testing/provision.py | 2 +- lib/sqlalchemy/testing/schema.py | 6 ++---- lib/sqlalchemy/testing/suite/test_reflection.py | 2 +- lib/sqlalchemy/testing/suite/test_types.py | 2 +- lib/sqlalchemy/testing/util.py | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 44551bd86..c8525f2f6 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -384,8 +384,8 @@ class ComparesTables(object): eq_(c.type.length, reflected_c.type.length) eq_( - set([f.column.name for f in c.foreign_keys]), - set([f.column.name for f in reflected_c.foreign_keys]) + {f.column.name for f in c.foreign_keys}, + {f.column.name for f in reflected_c.foreign_keys} ) if c.server_default: assert isinstance(reflected_c.server_default, @@ -440,7 +440,7 @@ class AssertsExecutionResults(object): return id(self) found = util.IdentitySet(result) - expected = set([immutabledict(e) for e in expected]) + expected = {immutabledict(e) for e in expected} for wrong in util.itertools_filterfalse(lambda o: isinstance(o, cls), found): diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index 7e4454465..83b6115fe 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -288,7 +288,7 @@ def reap_oracle_dbs(eng, idents_file): "select u.username from all_users u where username " "like 'TEST_%' and not exists (select username " "from v$session where username=u.username)") - all_names = set([username.lower() for (username, ) in to_reap]) + all_names = {username.lower() for (username, ) in to_reap} to_drop = set() for name in all_names: if name.endswith("_ts1") or name.endswith("_ts2"): diff --git a/lib/sqlalchemy/testing/schema.py b/lib/sqlalchemy/testing/schema.py index 018a291d9..f40654a2a 100644 --- a/lib/sqlalchemy/testing/schema.py +++ b/lib/sqlalchemy/testing/schema.py @@ -17,8 +17,7 @@ table_options = {} def Table(*args, **kw): """A schema.Table wrapper/hook for dialect-specific tweaks.""" - test_opts = dict([(k, kw.pop(k)) for k in list(kw) - if k.startswith('test_')]) + test_opts = {k: kw.pop(k) for k in list(kw) if k.startswith('test_')} kw.update(table_options) @@ -64,8 +63,7 @@ def Table(*args, **kw): def Column(*args, **kw): """A schema.Column wrapper/hook for dialect-specific tweaks.""" - test_opts = dict([(k, kw.pop(k)) for k in list(kw) - if k.startswith('test_')]) + test_opts = {k: kw.pop(k) for k in list(kw) if k.startswith('test_')} if not config.requirements.foreign_key_ddl.enabled_for_config(config): args = [arg for arg in args if not isinstance(arg, schema.ForeignKey)] diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index a761c0882..f47b34bf4 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -746,7 +746,7 @@ class ComponentReflectionTest(fixtures.TablesTest): ('dingalings', 'dingaling_id'), ]: cols = insp.get_columns(tname) - id_ = dict((c['name'], c) for c in cols)[cname] + id_ = {c['name']: c for c in cols}[cname] assert id_.get('autoincrement', True) diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index dbbe03111..ee757e1ca 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -340,7 +340,7 @@ class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase): t.create() t.insert().execute([{'x': x} for x in input_]) - result = set([row[0] for row in t.select().execute()]) + result = {row[0] for row in t.select().execute()} output = set(output) if filter_: result = set(filter_(x) for x in result) diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py index 8f91f31ed..a37637ac0 100644 --- a/lib/sqlalchemy/testing/util.py +++ b/lib/sqlalchemy/testing/util.py @@ -173,7 +173,7 @@ def rowset(results): Useful for asserting the results of an unordered query. """ - return set([tuple(row) for row in results]) + return {tuple(row) for row in results} def fail(msg): -- cgit v1.2.1