forked from fgmacedo/python-statemachine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
23 lines (17 loc) · 803 Bytes
/
conftest.py
File metadata and controls
23 lines (17 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()