diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-05-26 19:06:13 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-05-26 19:06:13 -0400 |
commit | 6cde27fe9161a21b075c7b8faa09d1e77169f1f2 (patch) | |
tree | d7d986fa78683a7e570dd1e6da84e7bb4ca1b762 /lib/sqlalchemy/testing/engines.py | |
parent | 29689fa566ba1bd3dc08727754632c9e8074137c (diff) | |
download | sqlalchemy-6cde27fe9161a21b075c7b8faa09d1e77169f1f2.tar.gz |
a pass where we try to squash down as many list()/keys() combinations
as possible
Diffstat (limited to 'lib/sqlalchemy/testing/engines.py')
-rw-r--r-- | lib/sqlalchemy/testing/engines.py | 42 |
1 files changed, 20 insertions, 22 deletions
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() |