forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
58 lines (45 loc) · 1.54 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
# -*- coding: utf-8 -*-
import pytest
from django.conf import settings
from rest_framework.test import APIClient
try:
# TODO: this file is read/executed even when called from ``readthedocsinc``,
# so it's overriding the options that we are defining in the ``conftest.py``
# from the corporate site. We need to find a better way to avoid this.
import readthedocsinc
PYTEST_OPTIONS = ()
except ImportError:
PYTEST_OPTIONS = (
# Options to set test environment
('community', True),
('corporate', False),
('environment', 'readthedocs'),
('url_scheme', 'http'),
)
def pytest_addoption(parser):
parser.addoption(
'--including-search',
action='store_true',
dest='searchtests',
default=False, help='enable search tests',
)
def pytest_configure(config):
if not config.option.searchtests:
# Include ``not search``` to parameters so search tests do not perform
markexpr = getattr(config.option, 'markexpr')
if markexpr:
markexpr += ' and not search'
else:
markexpr = 'not search'
setattr(config.option, 'markexpr', markexpr.strip())
for option, value in PYTEST_OPTIONS:
setattr(config.option, option, value)
@pytest.fixture(autouse=True)
def settings_modification(settings):
settings.CELERY_ALWAYS_EAGER = True
@pytest.fixture
def api_client():
return APIClient()
@pytest.fixture(scope="class")
def url_scheme(request):
request.cls.url_scheme = request.config.option.url_scheme