]> git.ipfire.org Git - thirdparty/psycopg.git/commit
test: use anyio instead of pytest-asyncio 352/head
authorDenis Laxalde <denis.laxalde@dalibo.com>
Wed, 17 Aug 2022 13:59:31 +0000 (15:59 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 4 Feb 2023 11:47:43 +0000 (12:47 +0100)
commitb6cc8343159fc0a27365e09a3beef06433f3f1b5
tree99aeda722b21b87384e2da75a159c85223c3433b
parentc4db82c557fa14b8cc6af594a01a130a3e588259
test: use anyio instead of pytest-asyncio

This is in preparation for adding support for other async libraries,
through anyio. AnyIO pytest plugin is used in replacement for
pytest-asyncio:

- either the pytest.mark.asyncio is replaced by pytest.mark.anyio, or,
- we rely on the 'anyio_backend' fixture that is pulled in 'aconn_cls'
  fixture (and hence 'aconn') providing automatic detection for test
  functions using it.

The 'anyio_backend' fixture is parametrized to only use asyncio and
selects the event loop policy we need on Windows platform as previously
done in pytest_sessionstart(), but only for Python version 3.8 or
higher.

This fixture is defined in main conftest.py, as well as in
pool/conftest.py since we'll change the former to support more async
backend while keeping the later asyncio-only for now.

Function test_concurrency_async.py::test_ctrl_c is no longer 'async'
because its code does not directly use asyncio (it's done through a
subprocess); but the 'async def' was needed before in order for
pytest-asyncio to run it since the test module had a global
pytest.mark.asyncio (and we were using the "auto" mode).
32 files changed:
psycopg/setup.cfg
pyproject.toml
tests/conftest.py
tests/constraints.txt
tests/crdb/test_connection_async.py
tests/crdb/test_copy_async.py
tests/crdb/test_cursor_async.py
tests/fix_db.py
tests/pool/conftest.py [new file with mode: 0644]
tests/pool/test_null_pool_async.py
tests/pool/test_pool_async.py
tests/pool/test_sched_async.py
tests/test_client_cursor_async.py
tests/test_concurrency_async.py
tests/test_connection_async.py
tests/test_conninfo.py
tests/test_copy_async.py
tests/test_cursor_async.py
tests/test_dns.py
tests/test_dns_srv.py
tests/test_errors.py
tests/test_pipeline_async.py
tests/test_prepared_async.py
tests/test_server_cursor_async.py
tests/test_tpc_async.py
tests/test_transaction_async.py
tests/test_typeinfo.py
tests/test_waiting.py
tests/types/test_composite.py
tests/types/test_enum.py
tests/types/test_multirange.py
tests/types/test_range.py