From 55ede24d562e12b9a6ff87678b13b3223af3f1f7 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Fri, 14 Sep 2018 14:13:33 +0200 Subject: [PATCH] MAINT: skip doctest for Python 2 (#12074) --- conftest.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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):