| 1 |
========================================================= |
| 2 |
How to run a test with specific event loop factories only |
| 3 |
========================================================= |
| 4 |
|
| 5 |
``pytest_asyncio_loop_factories`` determines which named event loop factories are available for each test item. |
| 6 |
By default, pytest-asyncio parametrizes a test with every factory returned for that item. |
| 7 |
Use ``loop_factories`` to select a subset of the factory names returned by the hook. |
| 8 |
|
| 9 |
Assume ``conftest.py`` provides two named factories: |
| 10 |
|
| 11 |
.. include:: run_test_with_specific_loop_factories/conftest.py |
| 12 |
:code: python |
| 13 |
|
| 14 |
Then use ``loop_factories`` to select which available factory names a test should run with: |
| 15 |
|
| 16 |
.. include:: run_test_with_specific_loop_factories/test_loop_factories_subset.py |
| 17 |
:code: python |
| 18 |
|
| 19 |
If a requested factory name is not available from the hook, the test variant for that factory is skipped. |
| 20 |
|
| 21 |
For declaring the factories themselves, see :doc:`custom_loop_factory`. |
| 22 |
|
| 23 |
For choosing the available factories from the pytest item, see :doc:`configure_loop_factories_per_test`. |