-
Notifications
You must be signed in to change notification settings - Fork 10
/
conftest.py
63 lines (43 loc) · 1.46 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
"""Configuration and injectable fixtures for Pytest.
Reuses fixtures defined in abilian-core.
"""
import logging
import os
from pytest import fixture
from abilian.sbe.app import create_app
from abilian.testing.fixtures import TestConfig
pytest_plugins = [
"abilian.testing.fixtures",
"abilian.sbe.apps.communities.tests.fixtures",
]
if os.environ.get("COLLECT_ANNOTATIONS"):
def pytest_collection_finish(session):
"""Handle the pytest collection finish hook: configure pyannotate.
Explicitly delay importing `collect_types` until all tests have
been collected. This gives gevent a chance to monkey patch the
world before importing pyannotate.
"""
from pyannotate_runtime import collect_types
collect_types.init_types_collection()
@fixture(autouse=True)
def collect_types_fixture():
from pyannotate_runtime import collect_types
collect_types.resume()
yield
collect_types.pause()
def pytest_sessionfinish(session, exitstatus):
from pyannotate_runtime import collect_types
collect_types.dump_stats("type_info.json")
class NoCsrfTestConfig(TestConfig):
WTF_CSRF_ENABLED = False
@fixture
def config():
return NoCsrfTestConfig
@fixture
def app(config):
"""Return an App configured with config=TestConfig."""
return create_app(config=config)
@fixture
def req_ctx(app, request_ctx):
"""Simple alias (TBR)"""
return request_ctx