-
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathconftest.py
More file actions
48 lines (33 loc) · 1.37 KB
/
conftest.py
File metadata and controls
48 lines (33 loc) · 1.37 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import shutil
import sys
import pytest
@pytest.fixture(autouse=True, scope="session")
def add_doctest_context(doctest_namespace): # noqa: PT004
from statemachine.utils import run_async_from_sync
from statemachine import State
from statemachine import StateChart
from statemachine import StateMachine
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["StateChart"] = StateChart
doctest_namespace["StateMachine"] = StateMachine
doctest_namespace["asyncio"] = ContribAsyncio()
def pytest_ignore_collect(collection_path, config):
if sys.version_info >= (3, 10): # noqa: UP036
return None
if "django_project" in str(collection_path):
return True
@pytest.fixture(scope="session")
def has_dot_installed():
return bool(shutil.which("dot"))
@pytest.fixture()
def requires_dot_installed(request, has_dot_installed):
if not has_dot_installed:
pytest.skip(f"Test {request.node.nodeid} requires 'dot' that is not installed.")