diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-02 21:43:53 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-03-02 21:47:01 -0500 |
commit | 43cf4a9e5d66946a6a982ab3e1e513bb426eb35b (patch) | |
tree | 0a5668a56cf3e1de2488455aed076941b5b7f15c /test/ext/asyncio/test_engine_py3k.py | |
parent | 3fd1a52794c5463854fe36cbe97595d8489bbf62 (diff) | |
download | sqlalchemy-43cf4a9e5d66946a6a982ab3e1e513bb426eb35b.tar.gz |
improve error raise for dialect/pool events w/ async engine
Fixed issues where a descriptive error message was not raised for some
classes of event listening with an async engine, which should instead be a
sync engine instance.
Change-Id: I00b9f4fe9373ef5fd5464fac10651cc4024f648e
Diffstat (limited to 'test/ext/asyncio/test_engine_py3k.py')
-rw-r--r-- | test/ext/asyncio/test_engine_py3k.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ext/asyncio/test_engine_py3k.py b/test/ext/asyncio/test_engine_py3k.py index 1f40cbdec..0fe14dc92 100644 --- a/test/ext/asyncio/test_engine_py3k.py +++ b/test/ext/asyncio/test_engine_py3k.py @@ -651,6 +651,28 @@ class AsyncEventTest(EngineFixture): event.listen(conn, "before_cursor_execute", mock.Mock()) @async_test + async def test_no_async_listeners_dialect_event(self, async_engine): + with testing.expect_raises_message( + NotImplementedError, + "asynchronous events are not implemented " + "at this time. Apply synchronous listeners to the " + "AsyncEngine.sync_engine or " + "AsyncConnection.sync_connection attributes.", + ): + event.listen(async_engine, "do_execute", mock.Mock()) + + @async_test + async def test_no_async_listeners_pool_event(self, async_engine): + with testing.expect_raises_message( + NotImplementedError, + "asynchronous events are not implemented " + "at this time. Apply synchronous listeners to the " + "AsyncEngine.sync_engine or " + "AsyncConnection.sync_connection attributes.", + ): + event.listen(async_engine, "checkout", mock.Mock()) + + @async_test async def test_sync_before_cursor_execute_engine(self, async_engine): canary = mock.Mock() |