-
-
Notifications
You must be signed in to change notification settings - Fork 402
/
conftest.py
36 lines (26 loc) · 998 Bytes
/
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
import os
import pytest
def pytest_addoption(parser):
parser.addoption('--offline', action='store_true', default=False)
def pytest_collection_modifyitems(config, items):
# handle running tests in "offline mode"
if not config.getoption('--offline'):
# nothing to skip
return
skip_online = pytest.mark.skip(reason='deactivated when --offline is used')
for item in items:
if 'online' in item.keywords:
item.add_marker(skip_online)
def pytest_configure(config):
config.addinivalue_line(
'markers',
'online: for tests that require online access. '
'Use --offline to skip them.')
@pytest.fixture(scope='module')
def vcr_cassette_dir(request):
# Override VCR.py cassette save location, to keep them out of code folders
parts = request.module.__name__.split('.')
if parts[0] == 'sopel':
# We know it's part of Sopel...
parts = parts[1:]
return os.path.join('test', 'vcr', *parts)