forked from scikit-learn-contrib/imbalanced-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
33 lines (29 loc) · 1.11 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
# This file is here 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.
# Set numpy array str/repr to legacy behaviour on numpy > 1.13 to make
# the doctests pass
import os
import pytest
import numpy as np
try:
np.set_printoptions(legacy='1.13')
except TypeError:
pass
def pytest_runtest_setup(item):
fname = item.fspath.strpath
if (fname.endswith(os.path.join('keras', '_generator.py')) or
fname.endswith('miscellaneous.rst')):
try:
import keras
except ImportError:
pytest.skip('The keras package is not installed.')
elif (fname.endswith(os.path.join('tensorflow', '_generator.py')) or
fname.endswith('miscellaneous.rst')):
try:
import tensorflow
except ImportError:
pytest.skip('The tensorflow package is not installed.')