-
Notifications
You must be signed in to change notification settings - Fork 32
/
conftest.py
45 lines (32 loc) · 1.15 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
import dask
import pytest
@pytest.fixture(scope='function')
def threaded_scheduler():
with dask.config.set(scheduler='threads'):
yield
@pytest.fixture(scope='function')
def processes_scheduler():
with dask.config.set(scheduler='processes'):
yield
@pytest.fixture(scope='module')
def distributed_scheduler():
from dask.distributed import Client, LocalCluster
cluster = LocalCluster(threads_per_worker=1, n_workers=2, processes=True)
client = Client(cluster)
yield
client.close()
del client
cluster.close()
del cluster
def pytest_addoption(parser):
parser.addoption('--runtestcases', action='store_true', default=False, help='run test cases')
def pytest_configure(config):
config.addinivalue_line('markers', 'testcases: mark test cases')
def pytest_collection_modifyitems(config, items):
if config.getoption('--runtestcases'):
# --runtestcases given in cli: do not skip test cases
return
skip_testcases = pytest.mark.skip(reason='need --runtestcases option to run')
for item in items:
if 'testcases' in item.keywords:
item.add_marker(skip_testcases)