Skip to content

Commit c4f6008

Browse files
committed
TST/CI: Use pytest
update ci DOC Fixup runners added only-slow appveyor Move conftest
1 parent b268d89 commit c4f6008

20 files changed

+100
-67
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ dist
5656
**/wheelhouse/*
5757
# coverage
5858
.coverage
59+
coverage.xml
60+
coverage_html_report
5961

6062
# OS generated files #
6163
######################

.travis.yml

+19-19
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ matrix:
3232
env:
3333
- PYTHON_VERSION=3.5
3434
- JOB_NAME: "35_osx"
35-
- NOSE_ARGS="not slow and not network and not disabled"
35+
- NOSE_ARGS="--skip-slow --skip-network"
3636
- BUILD_TYPE=conda
3737
- JOB_TAG=_OSX
3838
- TRAVIS_PYTHON_VERSION=3.5
@@ -42,7 +42,7 @@ matrix:
4242
env:
4343
- PYTHON_VERSION=2.7
4444
- JOB_NAME: "27_slow_nnet_LOCALE"
45-
- NOSE_ARGS="slow and not network and not disabled"
45+
- NOSE_ARGS="--only-slow --skip-network"
4646
- LOCALE_OVERRIDE="zh_CN.UTF-8"
4747
- FULL_DEPS=true
4848
- JOB_TAG=_LOCALE
@@ -56,7 +56,7 @@ matrix:
5656
env:
5757
- PYTHON_VERSION=2.7
5858
- JOB_NAME: "27_nslow"
59-
- NOSE_ARGS="not slow and not disabled"
59+
- NOSE_ARGS="--skip-slow"
6060
- FULL_DEPS=true
6161
- CLIPBOARD_GUI=gtk2
6262
- LINT=true
@@ -70,7 +70,7 @@ matrix:
7070
env:
7171
- PYTHON_VERSION=3.5
7272
- JOB_NAME: "35_nslow"
73-
- NOSE_ARGS="not slow and not network and not disabled"
73+
- NOSE_ARGS="--skip-slow --skip-network"
7474
- FULL_DEPS=true
7575
- CLIPBOARD=xsel
7676
- COVERAGE=true
@@ -84,7 +84,7 @@ matrix:
8484
env:
8585
- PYTHON_VERSION=3.6
8686
- JOB_NAME: "36"
87-
- NOSE_ARGS="not slow and not network and not disabled"
87+
- NOSE_ARGS="--skip-slow --skip-network"
8888
- PANDAS_TESTING_MODE="deprecate"
8989
addons:
9090
apt:
@@ -96,7 +96,7 @@ matrix:
9696
env:
9797
- PYTHON_VERSION=2.7
9898
- JOB_NAME: "27_nslow_nnet_COMPAT"
99-
- NOSE_ARGS="not slow and not network and not disabled"
99+
- NOSE_ARGS="--skip-slow --skip-network"
100100
- LOCALE_OVERRIDE="it_IT.UTF-8"
101101
- INSTALL_TEST=true
102102
- JOB_TAG=_COMPAT
@@ -112,7 +112,7 @@ matrix:
112112
- PYTHON_VERSION=2.7
113113
- JOB_NAME: "27_slow"
114114
- JOB_TAG=_SLOW
115-
- NOSE_ARGS="slow and not network and not disabled"
115+
- NOSE_ARGS="--only-slow --skip-network"
116116
- FULL_DEPS=true
117117
- CACHE_NAME="27_slow"
118118
- USE_CACHE=true
@@ -122,7 +122,7 @@ matrix:
122122
- PYTHON_VERSION=2.7
123123
- JOB_NAME: "27_build_test_conda"
124124
- JOB_TAG=_BUILD_TEST
125-
- NOSE_ARGS="not slow and not disabled"
125+
- NOSE_ARGS="--skip-slow"
126126
- FULL_DEPS=true
127127
- BUILD_TEST=true
128128
- CACHE_NAME="27_build_test_conda"
@@ -133,7 +133,7 @@ matrix:
133133
- PYTHON_VERSION=3.4
134134
- JOB_NAME: "34_nslow"
135135
- LOCALE_OVERRIDE="zh_CN.UTF-8"
136-
- NOSE_ARGS="not slow and not disabled"
136+
- NOSE_ARGS="--skip-slow"
137137
- FULL_DEPS=true
138138
- CLIPBOARD=xsel
139139
- CACHE_NAME="34_nslow"
@@ -149,7 +149,7 @@ matrix:
149149
- PYTHON_VERSION=3.4
150150
- JOB_NAME: "34_slow"
151151
- JOB_TAG=_SLOW
152-
- NOSE_ARGS="slow and not network and not disabled"
152+
- NOSE_ARGS="--only-slow --skip-network"
153153
- FULL_DEPS=true
154154
- CLIPBOARD=xsel
155155
- CACHE_NAME="34_slow"
@@ -164,7 +164,7 @@ matrix:
164164
- PYTHON_VERSION=3.5
165165
- JOB_NAME: "35_numpy_dev"
166166
- JOB_TAG=_NUMPY_DEV
167-
- NOSE_ARGS="not slow and not network and not disabled"
167+
- NOSE_ARGS="--skip-slow --skip-network"
168168
- PANDAS_TESTING_MODE="deprecate"
169169
- CACHE_NAME="35_numpy_dev"
170170
- USE_CACHE=true
@@ -179,7 +179,7 @@ matrix:
179179
- PYTHON_VERSION=3.5
180180
- JOB_NAME: "35_ascii"
181181
- JOB_TAG=_ASCII
182-
- NOSE_ARGS="not slow and not network and not disabled"
182+
- NOSE_ARGS="--skip-slow --skip-network"
183183
- LOCALE_OVERRIDE="C"
184184
- CACHE_NAME="35_ascii"
185185
- USE_CACHE=true
@@ -199,7 +199,7 @@ matrix:
199199
- PYTHON_VERSION=2.7
200200
- JOB_NAME: "27_slow"
201201
- JOB_TAG=_SLOW
202-
- NOSE_ARGS="slow and not network and not disabled"
202+
- NOSE_ARGS="--only-slow --skip-network"
203203
- FULL_DEPS=true
204204
- CACHE_NAME="27_slow"
205205
- USE_CACHE=true
@@ -208,7 +208,7 @@ matrix:
208208
- PYTHON_VERSION=3.4
209209
- JOB_NAME: "34_slow"
210210
- JOB_TAG=_SLOW
211-
- NOSE_ARGS="slow and not network and not disabled"
211+
- NOSE_ARGS="--only-slow --skip-network"
212212
- FULL_DEPS=true
213213
- CLIPBOARD=xsel
214214
- CACHE_NAME="34_slow"
@@ -222,7 +222,7 @@ matrix:
222222
- PYTHON_VERSION=2.7
223223
- JOB_NAME: "27_build_test_conda"
224224
- JOB_TAG=_BUILD_TEST
225-
- NOSE_ARGS="not slow and not disabled"
225+
- NOSE_ARGS="--skip-slow"
226226
- FULL_DEPS=true
227227
- BUILD_TEST=true
228228
- CACHE_NAME="27_build_test_conda"
@@ -232,7 +232,7 @@ matrix:
232232
- PYTHON_VERSION=3.4
233233
- JOB_NAME: "34_nslow"
234234
- LOCALE_OVERRIDE="zh_CN.UTF-8"
235-
- NOSE_ARGS="not slow and not disabled"
235+
- NOSE_ARGS="--skip-slow"
236236
- FULL_DEPS=true
237237
- CLIPBOARD=xsel
238238
- CACHE_NAME="34_nslow"
@@ -247,7 +247,7 @@ matrix:
247247
- PYTHON_VERSION=3.5
248248
- JOB_NAME: "35_numpy_dev"
249249
- JOB_TAG=_NUMPY_DEV
250-
- NOSE_ARGS="not slow and not network and not disabled"
250+
- NOSE_ARGS="--skip-slow --skip-network"
251251
- PANDAS_TESTING_MODE="deprecate"
252252
- CACHE_NAME="35_numpy_dev"
253253
- USE_CACHE=true
@@ -260,7 +260,7 @@ matrix:
260260
env:
261261
- PYTHON_VERSION=2.7
262262
- JOB_NAME: "27_nslow_nnet_COMPAT"
263-
- NOSE_ARGS="not slow and not network and not disabled"
263+
- NOSE_ARGS="--skip-slow --skip-network"
264264
- LOCALE_OVERRIDE="it_IT.UTF-8"
265265
- INSTALL_TEST=true
266266
- JOB_TAG=_COMPAT
@@ -275,7 +275,7 @@ matrix:
275275
- PYTHON_VERSION=3.5
276276
- JOB_NAME: "35_ascii"
277277
- JOB_TAG=_ASCII
278-
- NOSE_ARGS="not slow and not network and not disabled"
278+
- NOSE_ARGS="--skip-slow --skip-network"
279279
- LOCALE_OVERRIDE="C"
280280
- CACHE_NAME="35_ascii"
281281
- USE_CACHE=true

appveyor.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ environment:
1414
# /E:ON and /V:ON options are not enabled in the batch script intepreter
1515
# See: http://stackoverflow.com/a/13751649/163740
1616
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
17+
clone_folder: C:\projects\pandas
1718

1819
matrix:
1920

@@ -82,7 +83,7 @@ install:
8283
- cmd: '%CMD_IN_ENV% conda build ci\appveyor.recipe -q'
8384

8485
# create our env
85-
- cmd: conda create -q -n pandas python=%PYTHON_VERSION% nose
86+
- cmd: conda create -q -n pandas python=%PYTHON_VERSION% nose pytest
8687
- cmd: activate pandas
8788
- SET REQ=ci\requirements-%PYTHON_VERSION%-%PYTHON_ARCH%.run
8889
- cmd: echo "installing requirements from %REQ%"
@@ -93,7 +94,8 @@ install:
9394

9495
test_script:
9596
# tests
96-
- cd \
9797
- cmd: activate pandas
9898
- cmd: conda list
99-
- cmd: nosetests --exe -A "not slow and not network and not disabled" pandas
99+
- cmd: cd \
100+
- cmd: python -c "import pandas; pandas.test(['--skip-slow', '--skip-network'])"
101+

ci/install_test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if [ "$INSTALL_TEST" ]; then
88
conda uninstall cython || exit 1
99
python "$TRAVIS_BUILD_DIR"/setup.py sdist --formats=zip,gztar || exit 1
1010
pip install "$TRAVIS_BUILD_DIR"/dist/*tar.gz || exit 1
11-
nosetests --exe -A "$NOSE_ARGS" pandas/tests/test_series.py --with-xunit --xunit-file=/tmp/nosetests_install.xml
11+
# nosetests --exe -A "$NOSE_ARGS" pandas/tests/test_series.py --with-xunit --xunit-file=/tmp/nosetests_install.xml
12+
pytest pandas/tests/test_series.py --junitxml=/tmp/pytest_install.xml
1213
else
1314
echo "Skipping installation test."
1415
fi

ci/install_travis.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,17 @@ else
8383

8484
# Useful for debugging any issues with conda
8585
conda info -a || exit 1
86+
8687
fi
8788

8889
# may have installation instructions for this build
8990
INSTALL="ci/install-${PYTHON_VERSION}${JOB_TAG}.sh"
9091
if [ -e ${INSTALL} ]; then
9192
time bash $INSTALL || exit 1
9293
else
93-
9494
# create new env
95-
time conda create -n pandas python=$PYTHON_VERSION nose || exit 1
95+
time conda create -n pandas python=$PYTHON_VERSION nose pytest || exit 1
9696

97-
if [ "$COVERAGE" ]; then
98-
pip install coverage
99-
fi
10097
if [ "$LINT" ]; then
10198
conda install flake8
10299
pip install cpplint
@@ -119,6 +116,10 @@ fi
119116

120117
source activate pandas
121118

119+
if [ "$COVERAGE" ]; then
120+
pip install coverage pytest-cov
121+
fi
122+
122123
if [ "$BUILD_TEST" ]; then
123124

124125
# build testing

ci/requirements_all.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
nose
2+
pytest
3+
pytest-cov
24
flake8
35
sphinx
46
ipython

ci/requirements_dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ pytz
33
numpy
44
cython
55
nose
6+
pytest
7+
pytest-cov
68
flake8

ci/script.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ fi
2020
if [ "$BUILD_TEST" ]; then
2121
echo "We are not running nosetests as this is simply a build test."
2222
elif [ "$COVERAGE" ]; then
23-
echo nosetests --exe -A "$NOSE_ARGS" pandas --with-coverage --with-xunit --xunit-file=/tmp/nosetests.xml
24-
nosetests --exe -A "$NOSE_ARGS" pandas --with-coverage --cover-package=pandas --cover-tests --with-xunit --xunit-file=/tmp/nosetests.xml
23+
echo pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $NOSE_ARGS pandas
24+
pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $NOSE_ARGS pandas
2525
else
26-
echo nosetests --exe -A "$NOSE_ARGS" pandas --doctest-tests --with-xunit --xunit-file=/tmp/nosetests.xml
27-
nosetests --exe -A "$NOSE_ARGS" pandas --doctest-tests --with-xunit --xunit-file=/tmp/nosetests.xml
26+
echo pytest $NOSE_ARGS pandas
27+
pytest $NOSE_ARGS pandas # TODO: doctest
2828
fi
2929

3030
RET="$?"

doc/source/contributing.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ use cases and writing corresponding tests.
552552
Adding tests is one of the most common requests after code is pushed to *pandas*. Therefore,
553553
it is worth getting in the habit of writing tests ahead of time so this is never an issue.
554554

555-
Like many packages, *pandas* uses the `Nose testing system
556-
<https://nose.readthedocs.io/en/latest/index.html>`_ and the convenient
555+
Like many packages, *pandas* uses `pytest`
556+
<http://doc.pytest.org/en/latest/>`_ and the convenient
557557
extensions in `numpy.testing
558558
<http://docs.scipy.org/doc/numpy/reference/routines.testing.html>`_.
559559

@@ -595,15 +595,15 @@ Running the test suite
595595
The tests can then be run directly inside your Git clone (without having to
596596
install *pandas*) by typing::
597597

598-
nosetests pandas
598+
pytest pandas
599599

600600
The tests suite is exhaustive and takes around 20 minutes to run. Often it is
601601
worth running only a subset of tests first around your changes before running the
602602
entire suite. This is done using one of the following constructs::
603603

604-
nosetests pandas/tests/[test-module].py
605-
nosetests pandas/tests/[test-module].py:[TestClass]
606-
nosetests pandas/tests/[test-module].py:[TestClass].[test_method]
604+
pytest pandas/tests/[test-module].py
605+
pytest pandas/tests/[test-module].py::[TestClass]
606+
pytest pandas/tests/[test-module].py::[TestClass]::[test_method]
607607

608608
.. versionadded:: 0.18.0
609609

doc/source/install.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ Running the test suite
188188
pandas is equipped with an exhaustive set of unit tests covering about 97% of
189189
the codebase as of this writing. To run it on your machine to verify that
190190
everything is working (and you have all of the dependencies, soft and hard,
191-
installed), make sure you have `nose
192-
<https://nose.readthedocs.io/en/latest/>`__ and run:
191+
installed), make sure you have `pytest
192+
<http://doc.pytest.org/en/latest/>`__ and run:
193193

194194
::
195195

pandas/api/tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestPDApi(Base, tm.TestCase):
2828

2929
# these are optionally imported based on testing
3030
# & need to be ignored
31-
ignored = ['tests', 'locale']
31+
ignored = ['tests', 'locale', 'conftest']
3232

3333
# top-level sub-packages
3434
lib = ['api', 'compat', 'computation', 'core',

pandas/conftest.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
3+
4+
def pytest_addoption(parser):
5+
parser.addoption("--skip-slow", action="store_true",
6+
help="skip slow tests")
7+
parser.addoption("--skip-network", action="store_true",
8+
help="run network tests")
9+
parser.addoption("--only-slow", action="store_true",
10+
help="run only slow tests")
11+
parser.addoption("--run-disabled", action="store_false",
12+
help="run disabled tests")
13+
14+
15+
def pytest_runtest_setup(item):
16+
if 'slow' in item.keywords and item.config.getoption("--skip-slow"):
17+
pytest.skip("skipping due to --skip-slow")
18+
19+
if 'slow' not in item.keywords and item.config.getoption("--only-slow"):
20+
pytest.skip("skipping due to --only-slow")
21+
22+
if 'skip' in item.keywords and item.config.getoption("--skip-network"):
23+
pytest.skip("skipping due to --skip-network")
24+
25+
if 'disabled' in item.keywords and item.config.getoption("--run-disabled"):
26+
pytest.skip("need --run-disabled option to run")

pandas/util/testing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from distutils.version import LooseVersion
2020

2121
from numpy.random import randn, rand
22-
from numpy.testing.decorators import slow # noqa
22+
# from numpy.testing.decorators import slow # noqa
23+
import pytest
2324
import numpy as np
2425

2526
import pandas as pd
@@ -2549,9 +2550,8 @@ def assert_produces_warning(expected_warning=Warning, filter_level="always",
25492550
% extra_warnings)
25502551

25512552

2552-
def disabled(t):
2553-
t.disabled = True
2554-
return t
2553+
disabled = pytest.mark.disabled
2554+
slow = pytest.mark.slow
25552555

25562556

25572557
class RNGContext(object):

setup.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ based_on_style = pep8
1919
split_before_named_assigns = false
2020
split_penalty_after_opening_bracket = 1000000
2121
split_penalty_logical_operator = 30
22+
23+
[tool:pytest]
24+
# TODO: Change all yield-based (nose-style) fixutures to pytest fixtures
25+
# Silencing the warning until then
26+
addopts = --disable-pytest-warnings
27+
testpaths = pandas

test.bat

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
:: test on windows
22

3-
nosetests --exe -A "not slow and not network and not disabled" pandas %*
3+
:: nosetests --exe -A "not slow and not network and not disabled" pandas %*
4+
pytest pandas

0 commit comments

Comments
 (0)