File: uvloop.rst

package info (click to toggle)
python-pytest-asyncio 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 616 kB
  • sloc: python: 2,421; makefile: 24; sh: 1
file content (18 lines) | stat: -rw-r--r-- 646 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
=======================
How to test with uvloop
=======================

Redefining the *event_loop_policy* fixture will parametrize all async tests. The following example causes all async tests to run multiple times, once for each event loop in the fixture parameters:
Replace the default event loop policy in your *conftest.py:*

.. code-block:: python

    import pytest
    import uvloop


    @pytest.fixture(scope="session")
    def event_loop_policy():
        return uvloop.EventLoopPolicy()

You may choose to limit the scope of the fixture to *package,* *module,* or *class,* if you only want a subset of your tests to run with uvloop.