forked from scikit-learn/scikit-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
31 lines (25 loc) · 1.07 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
# Even if empty this file is useful so that when running from the root folder
# ./sklearn is added to sys.path by pytest. See
# https://docs.pytest.org/en/latest/pythonpath.html for more details. For
# example, this allows to build extensions in place and run pytest
# doc/modules/clustering.rst and use sklearn from the local folder rather than
# the one from site-packages.
from distutils.version import LooseVersion
import pytest
from _pytest.doctest import DoctestItem
def pytest_collection_modifyitems(config, items):
# numpy changed the str/repr formatting of numpy arrays in 1.14. We want to
# run doctests only for numpy >= 1.14.
skip_doctests = True
try:
import numpy as np
if LooseVersion(np.__version__) >= LooseVersion('1.14'):
skip_doctests = False
except ImportError:
pass
if skip_doctests:
skip_marker = pytest.mark.skip(
reason='doctests are only run for numpy >= 1.14')
for item in items:
if isinstance(item, DoctestItem):
item.add_marker(skip_marker)