diff --git a/conftest.py b/conftest.py index bad99b5c99272..823a13221075b 100644 --- a/conftest.py +++ b/conftest.py @@ -11,6 +11,8 @@ import pytest from _pytest.doctest import DoctestItem +from sklearn.utils.fixes import PY3_OR_LATER + PYTEST_MIN_VERSION = '3.3.0' if LooseVersion(pytest.__version__) < PYTEST_MIN_VERSION: @@ -28,18 +30,21 @@ def pytest_collection_modifyitems(config, items): item.add_marker(skip_marker) # 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 + # run doctests only for numpy >= 1.14. We want to skip the doctest for + # python 2 due to unicode. + skip_doctests = False + if not PY3_OR_LATER: + skip_doctests = True try: import numpy as np - if LooseVersion(np.__version__) >= LooseVersion('1.14'): - skip_doctests = False + if LooseVersion(np.__version__) < LooseVersion('1.14'): + skip_doctests = True except ImportError: pass if skip_doctests: skip_marker = pytest.mark.skip( - reason='doctests are only run for numpy >= 1.14') + reason='doctests are only run for numpy >= 1.14 and python >= 3') for item in items: if isinstance(item, DoctestItem):