diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-02 10:55:21 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-02 19:08:25 -0500 |
| commit | 5ba427f6daad4e7224267d11f7c6d99bd68f3d0e (patch) | |
| tree | a6c7c112c0eb078521b0281c804578a63aa3810f /lib/sqlalchemy/testing/engines.py | |
| parent | 2581655c545a0cf705e0347e81cd092896d3207c (diff) | |
| download | sqlalchemy-5ba427f6daad4e7224267d11f7c6d99bd68f3d0e.tar.gz | |
Repair async test refactor
in I4940d184a4dc790782fcddfb9873af3cca844398 we reworked how async
tests run but apparently the async tests in test/ext/asyncio
are reporting success without being run. This patch pushes
pytestplugin further so that it won't instrument any test
or function overall that declares itself async. This removes
the need for the __async_wrap__ flag and also allows us to
use a more strict "run_async_test" function that always
runs the asyncio event loop from the top.
Also start working asyncio into main testing suite.
Change-Id: If7144e951a9db67eb7ea73b377f81c4440d39819
Diffstat (limited to 'lib/sqlalchemy/testing/engines.py')
| -rw-r--r-- | lib/sqlalchemy/testing/engines.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index d0a1bc0d0..4d4563afb 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -97,7 +97,10 @@ class ConnectionKiller(object): self.conns = set() for rec in list(self.testing_engines): - rec.dispose() + if hasattr(rec, "sync_engine"): + rec.sync_engine.dispose() + else: + rec.dispose() def assert_all_closed(self): for rec in self.proxy_refs: @@ -236,10 +239,12 @@ def reconnecting_engine(url=None, options=None): return engine -def testing_engine(url=None, options=None, future=False): +def testing_engine(url=None, options=None, future=False, asyncio=False): """Produce an engine configured by --options with optional overrides.""" - if future or config.db and config.db._is_future: + if asyncio: + from sqlalchemy.ext.asyncio import create_async_engine as create_engine + elif future or config.db and config.db._is_future: from sqlalchemy.future import create_engine else: from sqlalchemy import create_engine @@ -263,7 +268,10 @@ def testing_engine(url=None, options=None, future=False): default_opt.update(options) engine = create_engine(url, **options) - engine._has_events = True # enable event blocks, helps with profiling + if asyncio: + engine.sync_engine._has_events = True + else: + engine._has_events = True # enable event blocks, helps with profiling if isinstance(engine.pool, pool.QueuePool): engine.pool._timeout = 0 |
