-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
conftest.py
33 lines (23 loc) · 1005 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
import pytest
@pytest.fixture(autouse=True, scope="session")
def add_doctest_context(doctest_namespace): # noqa: PT004
from statemachine import State
from statemachine import StateMachine
from statemachine.utils import run_async_from_sync
class ContribAsyncio:
"""
Using `run_async_from_sync` to be injected in the doctests to better integration with an
already running loop, as all of our examples are also automated executed as doctests.
On real life code you should use standard `import asyncio; asyncio.run(main())`.
"""
def __init__(self):
self.run = run_async_from_sync
doctest_namespace["State"] = State
doctest_namespace["StateMachine"] = StateMachine
doctest_namespace["asyncio"] = ContribAsyncio()
def pytest_ignore_collect(collection_path, path, config):
if sys.version_info >= (3, 10): # noqa: UP036
return None
if "django_project" in str(path):
return True