-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
conftest.py
66 lines (46 loc) · 1.24 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# SPDX-FileCopyrightText: 2023 Hynek Schlawack <[email protected]>
#
# SPDX-License-Identifier: MIT
from doctest import ELLIPSIS
import pytest
from sybil import Sybil
from sybil.parsers import myst, rest
import svcs
from tests.helpers import CloseMe
from tests.ifaces import Service
markdown_examples = Sybil(
parsers=[
myst.DocTestDirectiveParser(optionflags=ELLIPSIS),
myst.PythonCodeBlockParser(doctest_optionflags=ELLIPSIS),
myst.SkipParser(),
],
patterns=["*.md"],
)
rest_examples = Sybil(
parsers=[
rest.DocTestParser(optionflags=ELLIPSIS),
rest.PythonCodeBlockParser(),
],
patterns=["*.py"],
)
pytest_collect_file = (markdown_examples + rest_examples).pytest()
collect_ignore = []
try:
import sphinx # noqa: F401
except ImportError:
collect_ignore.extend(["docs"])
@pytest.fixture(name="svc")
def _svc():
return Service()
@pytest.fixture(name="rs")
def _rs(svc):
return svcs.RegisteredService(Service, Service, False, True, None)
@pytest.fixture(name="registry")
def _registry():
return svcs.Registry()
@pytest.fixture(name="container")
def _container(registry):
return svcs.Container(registry)
@pytest.fixture(name="close_me")
def _close_me():
return CloseMe()