Skip to content

Commit 144df0f

Browse files
committed
TST/CI: Use pytest
update ci DOC Fixup runners
1 parent bc5534d commit 144df0f

19 files changed

+78
-42
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dist
5555
**/wheelhouse/*
5656
# coverage
5757
.coverage
58+
coverage_html_report
5859

5960
# OS generated files #
6061
######################

.travis.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ matrix:
3535
osx_image: xcode6.4
3636
env:
3737
- JOB_NAME: "35_osx"
38-
- NOSE_ARGS="not slow and not network and not disabled"
38+
- NOSE_ARGS="--skip-slow --skip-network"
3939
- BUILD_TYPE=conda
4040
- JOB_TAG=_OSX
4141
- TRAVIS_PYTHON_VERSION=3.5
@@ -44,7 +44,7 @@ matrix:
4444
- python: 2.7
4545
env:
4646
- JOB_NAME: "27_slow_nnet_LOCALE"
47-
- NOSE_ARGS="slow and not network and not disabled"
47+
- NOSE_ARGS="--skip-network"
4848
- LOCALE_OVERRIDE="zh_CN.UTF-8"
4949
- FULL_DEPS=true
5050
- JOB_TAG=_LOCALE
@@ -57,7 +57,7 @@ matrix:
5757
- python: 2.7
5858
env:
5959
- JOB_NAME: "27_nslow"
60-
- NOSE_ARGS="not slow and not disabled"
60+
- NOSE_ARGS="--skip-slow"
6161
- FULL_DEPS=true
6262
- CLIPBOARD_GUI=gtk2
6363
- LINT=true
@@ -70,7 +70,7 @@ matrix:
7070
- python: 3.4
7171
env:
7272
- JOB_NAME: "34_nslow"
73-
- NOSE_ARGS="not slow and not disabled"
73+
- NOSE_ARGS="--skip-slow"
7474
- FULL_DEPS=true
7575
- CLIPBOARD=xsel
7676
- CACHE_NAME="34_nslow"
@@ -82,7 +82,7 @@ matrix:
8282
- python: 3.5
8383
env:
8484
- JOB_NAME: "35_nslow"
85-
- NOSE_ARGS="not slow and not network and not disabled"
85+
- NOSE_ARGS="--skip-slow --skip-network"
8686
- FULL_DEPS=true
8787
- CLIPBOARD=xsel
8888
- COVERAGE=true
@@ -97,7 +97,7 @@ matrix:
9797
env:
9898
- JOB_NAME: "27_slow"
9999
- JOB_TAG=_SLOW
100-
- NOSE_ARGS="slow and not network and not disabled"
100+
- NOSE_ARGS="--skip-network"
101101
- FULL_DEPS=true
102102
- CACHE_NAME="27_slow"
103103
- USE_CACHE=true
@@ -106,7 +106,7 @@ matrix:
106106
env:
107107
- JOB_NAME: "34_slow"
108108
- JOB_TAG=_SLOW
109-
- NOSE_ARGS="slow and not network and not disabled"
109+
- NOSE_ARGS="--skip-network"
110110
- FULL_DEPS=true
111111
- CLIPBOARD=xsel
112112
- CACHE_NAME="34_slow"
@@ -120,7 +120,7 @@ matrix:
120120
env:
121121
- JOB_NAME: "27_build_test_conda"
122122
- JOB_TAG=_BUILD_TEST
123-
- NOSE_ARGS="not slow and not disabled"
123+
- NOSE_ARGS="--skip-slow"
124124
- FULL_DEPS=true
125125
- BUILD_TEST=true
126126
- CACHE_NAME="27_build_test_conda"
@@ -130,7 +130,7 @@ matrix:
130130
env:
131131
- JOB_NAME: "35_numpy_dev"
132132
- JOB_TAG=_NUMPY_DEV
133-
- NOSE_ARGS="not slow and not network and not disabled"
133+
- NOSE_ARGS="--skip-slow --skip-network"
134134
- PANDAS_TESTING_MODE="deprecate"
135135
- CACHE_NAME="35_numpy_dev"
136136
- USE_CACHE=true
@@ -143,7 +143,7 @@ matrix:
143143
- python: 2.7
144144
env:
145145
- JOB_NAME: "27_nslow_nnet_COMPAT"
146-
- NOSE_ARGS="not slow and not network and not disabled"
146+
- NOSE_ARGS="--skip-slow --skip-network"
147147
- LOCALE_OVERRIDE="it_IT.UTF-8"
148148
- INSTALL_TEST=true
149149
- JOB_TAG=_COMPAT
@@ -176,15 +176,15 @@ matrix:
176176
env:
177177
- JOB_NAME: "27_slow"
178178
- JOB_TAG=_SLOW
179-
- NOSE_ARGS="slow and not network and not disabled"
179+
- NOSE_ARGS="--skip-network"
180180
- FULL_DEPS=true
181181
- CACHE_NAME="27_slow"
182182
- USE_CACHE=true
183183
- python: 3.4
184184
env:
185185
- JOB_NAME: "34_slow"
186186
- JOB_TAG=_SLOW
187-
- NOSE_ARGS="slow and not network and not disabled"
187+
- NOSE_ARGS="--skip-network"
188188
- FULL_DEPS=true
189189
- CLIPBOARD=xsel
190190
- CACHE_NAME="34_slow"
@@ -197,7 +197,7 @@ matrix:
197197
env:
198198
- JOB_NAME: "27_build_test_conda"
199199
- JOB_TAG=_BUILD_TEST
200-
- NOSE_ARGS="not slow and not disabled"
200+
- NOSE_ARGS="--skip-slow"
201201
- FULL_DEPS=true
202202
- BUILD_TEST=true
203203
- CACHE_NAME="27_build_test_conda"
@@ -206,7 +206,7 @@ matrix:
206206
env:
207207
- JOB_NAME: "35_numpy_dev"
208208
- JOB_TAG=_NUMPY_DEV
209-
- NOSE_ARGS="not slow and not network and not disabled"
209+
- NOSE_ARGS="--skip-slow --skip-network"
210210
- PANDAS_TESTING_MODE="deprecate"
211211
- CACHE_NAME="35_numpy_dev"
212212
- USE_CACHE=true
@@ -218,7 +218,7 @@ matrix:
218218
- python: 2.7
219219
env:
220220
- JOB_NAME: "27_nslow_nnet_COMPAT"
221-
- NOSE_ARGS="not slow and not network and not disabled"
221+
- NOSE_ARGS="--skip-slow --skip-network"
222222
- LOCALE_OVERRIDE="it_IT.UTF-8"
223223
- INSTALL_TEST=true
224224
- JOB_TAG=_COMPAT

appveyor.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ install:
9292
- cmd: '%CMD_IN_ENV% conda build ci\appveyor.recipe -q'
9393

9494
# create our env
95-
- cmd: conda create -q -n pandas python=%PYTHON_VERSION% nose
95+
- cmd: conda create -q -n pandas python=%PYTHON_VERSION% nose pytest
9696
- cmd: activate pandas
9797
- SET REQ=ci\requirements-%PYTHON_VERSION%-%PYTHON_ARCH%.run
9898
- cmd: echo "installing requirements from %REQ%"
@@ -104,4 +104,5 @@ test_script:
104104
- cd \
105105
- cmd: activate pandas
106106
- cmd: conda list
107-
- cmd: nosetests --exe -A "not slow and not network and not disabled" pandas
107+
# - cmd: nosetests --exe -A "not slow and not network and not disabled" pandas
108+
- cmd: pytest pandas --skipslow

ci/install_appveyor.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ function UpdateConda ($python_home) {
126126
function main () {
127127
InstallMiniconda $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
128128
UpdateConda $env:PYTHON
129-
InstallCondaPackages $env:PYTHON "pip setuptools nose"
129+
InstallCondaPackages $env:PYTHON "pip setuptools nose pytest"
130130
InstallCondaPackagesFromFile $env:PYTHON $env:PYTHON_VERSION $env:PYTHON_ARCH
131131
}
132132

133-
main
133+
main

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ else
8585
# Useful for debugging any issues with conda
8686
conda info -a || exit 1
8787

88-
time conda create -n pandas python=$TRAVIS_PYTHON_VERSION nose coverage flake8 || exit 1
88+
time conda create -n pandas python=$TRAVIS_PYTHON_VERSION nose pytest coverage flake8 || exit 1
8989

9090
fi
9191
# build deps

ci/requirements_all.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
nose
2+
pytest
23
flake8
34
sphinx
45
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 --junitxml=/tmp/nosetests.xml $NOSE_ARGS pandas
24+
pytest -s --cov=pandas --cov-report --junitxml=/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 --junitxml=/tmp/nosetests.xml $NOSE_ARGS pandas
27+
pytest --junitxml=/tmp/nosetests.xml $NOSE_ARGS pandas # TODO: doctest
2828
fi
2929

3030
RET="$?"

conftest.py

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

doc/source/contributing.rst

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

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

@@ -532,15 +532,15 @@ Running the test suite
532532
The tests can then be run directly inside your Git clone (without having to
533533
install *pandas*) by typing::
534534

535-
nosetests pandas
535+
pytest pandas
536536

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

541-
nosetests pandas/tests/[test-module].py
542-
nosetests pandas/tests/[test-module].py:[TestClass]
543-
nosetests pandas/tests/[test-module].py:[TestClass].[test_method]
541+
pytest pandas/tests/[test-module].py
542+
pytest pandas/tests/[test-module].py::[TestClass]
543+
pytest pandas/tests/[test-module].py::[TestClass]::[test_method]
544544

545545
.. versionadded:: 0.18.0
546546

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

setup.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ 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

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

test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ command -v python-coverage >/dev/null && python-coverage erase
44
# nosetests pandas/tests/test_index.py --with-coverage --cover-package=pandas.core --pdb-failure --pdb
55
#nosetests -w pandas --with-coverage --cover-package=pandas --pdb-failure --pdb #--cover-inclusive
66
#nosetests -A "not slow" -w pandas/tseries --with-coverage --cover-package=pandas.tseries $* #--cover-inclusive
7-
nosetests -w pandas --with-coverage --cover-package=pandas $*
7+
# nosetests -w pandas --with-coverage --cover-package=pandas $*
8+
pytest pandas --with-coverage --cover-package=pandas $*
89
# nosetests -w pandas/io --with-coverage --cover-package=pandas.io --pdb-failure --pdb
910
# nosetests -w pandas/core --with-coverage --cover-package=pandas.core --pdb-failure --pdb
1011
# nosetests -w pandas/stats --with-coverage --cover-package=pandas.stats

test_fast.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
nosetests -A "not slow and not network" pandas --with-id $*
1+
# nosetests -A "not slow and not network" pandas --with-id $*
2+
pytest pandas --skip-slow

test_multi.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
nosetests -A "not slow and not network" pandas --processes=4 $*
1+
# nosetests -A "not slow and not network" pandas --processes=4 $*
2+
pytest pandas

test_rebuild.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ python setup.py build_ext --inplace
55
coverage erase
66
# nosetests pandas/tests/test_index.py --with-coverage --cover-package=pandas.core --pdb-failure --pdb
77
#nosetests -w pandas --with-coverage --cover-package=pandas --pdb-failure --pdb #--cover-inclusive
8-
nosetests -w pandas --with-coverage --cover-package=pandas $* #--cover-inclusive
8+
# nosetests -w pandas --with-coverage --cover-package=pandas $* #--cover-inclusive
9+
pytest pandas --cov=pandas $* #--cover-inclusive
910
# nosetests -w pandas/io --with-coverage --cover-package=pandas.io --pdb-failure --pdb
1011
# nosetests -w pandas/core --with-coverage --cover-package=pandas.core --pdb-failure --pdb
1112
# nosetests -w pandas/stats --with-coverage --cover-package=pandas.stats

tox.ini

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ envlist = py27, py34, py35
1010
deps =
1111
cython
1212
nose
13+
pytest
1314
pytz>=2011k
1415
python-dateutil
1516
beautifulsoup4
@@ -26,7 +27,7 @@ changedir = {envdir}
2627

2728
commands =
2829
# TODO: --exe because of GH #761
29-
{envbindir}/nosetests --exe pandas {posargs:-A "not network and not disabled"}
30+
{envbindir}/pytest pandas {posargs:-A "not network and not disabled"}
3031
# cleanup the temp. build dir created by the tox build
3132
# /bin/rm -rf {toxinidir}/build
3233

@@ -63,18 +64,18 @@ usedevelop = True
6364
deps =
6465
{[testenv]deps}
6566
openpyxl<2.0.0
66-
commands = {envbindir}/nosetests {toxinidir}/pandas/io/tests/test_excel.py
67+
commands = {envbindir}/pytest {toxinidir}/pandas/io/tests/test_excel.py
6768

6869
[testenv:openpyxl20]
6970
usedevelop = True
7071
deps =
7172
{[testenv]deps}
7273
openpyxl<2.2.0
73-
commands = {envbindir}/nosetests {posargs} {toxinidir}/pandas/io/tests/test_excel.py
74+
commands = {envbindir}/pytest {posargs} {toxinidir}/pandas/io/tests/test_excel.py
7475

7576
[testenv:openpyxl22]
7677
usedevelop = True
7778
deps =
7879
{[testenv]deps}
7980
openpyxl>=2.2.0
80-
commands = {envbindir}/nosetests {posargs} {toxinidir}/pandas/io/tests/test_excel.py
81+
commands = {envbindir}/pytest {posargs} {toxinidir}/pandas/io/tests/test_excel.py

0 commit comments

Comments
 (0)