Skip to content

Commit

Permalink
MAINT: skip doctest for Python 2 (scikit-learn#12074)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre authored and qinhanmin2014 committed Sep 14, 2018
1 parent 1049fb1 commit 55ede24
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 55ede24

Please sign in to comment.