From 6cde27fe9161a21b075c7b8faa09d1e77169f1f2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 26 May 2013 19:06:13 -0400 Subject: a pass where we try to squash down as many list()/keys() combinations as possible --- lib/sqlalchemy/testing/engines.py | 42 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'lib/sqlalchemy/testing/engines.py') diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index cfaacc490..efc0103f2 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -8,7 +8,7 @@ from .util import decorator from .. import event, pool import re import warnings - +from .. import util class ConnectionKiller(object): @@ -37,12 +37,12 @@ class ConnectionKiller(object): "rollback/close connection: %s" % e) def rollback_all(self): - for rec in list(self.proxy_refs.keys()): + for rec in list(self.proxy_refs): if rec is not None and rec.is_valid: self._safe(rec.rollback) def close_all(self): - for rec in list(self.proxy_refs.keys()): + for rec in list(self.proxy_refs): if rec is not None: self._safe(rec._close) @@ -66,7 +66,7 @@ class ConnectionKiller(object): self.conns = set() - for rec in list(self.testing_engines.keys()): + for rec in list(self.testing_engines): if rec is not config.db: rec.dispose() @@ -75,7 +75,7 @@ class ConnectionKiller(object): for conn in self.conns: self._safe(conn.close) self.conns = set() - for rec in list(self.testing_engines.keys()): + for rec in list(self.testing_engines): rec.dispose() def assert_all_closed(self): @@ -353,24 +353,22 @@ class ReplayableSession(object): Callable = object() NoAttribute = object() -# start Py3K - Natives = set([getattr(types, t) - for t in dir(types) if not t.startswith('_')]). \ - union([type(t) if not isinstance(t, type) - else t for t in list(__builtins__.values())]).\ + if util.py2k: + Natives = set([getattr(types, t) + for t in dir(types) if not t.startswith('_')]).\ difference([getattr(types, t) - for t in ('FunctionType', 'BuiltinFunctionType', - 'MethodType', 'BuiltinMethodType', - 'LambdaType', )]) -# end Py3K -# start Py2K -# Natives = set([getattr(types, t) -# for t in dir(types) if not t.startswith('_')]). \ -# difference([getattr(types, t) -# for t in ('FunctionType', 'BuiltinFunctionType', -# 'MethodType', 'BuiltinMethodType', -# 'LambdaType', 'UnboundMethodType',)]) -# end Py2K + for t in ('FunctionType', 'BuiltinFunctionType', + 'MethodType', 'BuiltinMethodType', + 'LambdaType', 'UnboundMethodType',)]) + else: + Natives = set([getattr(types, t) + for t in dir(types) if not t.startswith('_')]).\ + union([type(t) if not isinstance(t, type) + else t for t in __builtins__.values()]).\ + difference([getattr(types, t) + for t in ('FunctionType', 'BuiltinFunctionType', + 'MethodType', 'BuiltinMethodType', + 'LambdaType', )]) def __init__(self): self.buffer = deque() -- cgit v1.2.1