forked from openai/baselines
-
Notifications
You must be signed in to change notification settings - Fork 725
/
conftest.py
22 lines (16 loc) · 924 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
"""Configures pytest to ignore certain unit tests unless the appropriate flag is passed.
--rungpu: tests that require GPU.
--expensive: tests that take a long time to run (e.g. training an RL algorithm for many timestesps)."""
import pytest
def pytest_addoption(parser):
parser.addoption("--rungpu", action="store_true", default=False, help="run gpu tests")
parser.addoption("--expensive", action="store_true",
help="run expensive tests (which are otherwise skipped).")
def pytest_collection_modifyitems(config, items):
flags = {'gpu': '--rungpu', 'expensive': '--expensive'}
skips = {keyword: pytest.mark.skip(reason="need {} option to run".format(flag))
for keyword, flag in flags.items() if not config.getoption(flag)}
for item in items:
for keyword, skip in skips.items():
if keyword in item.keywords:
item.add_marker(skip)