Skip to content

Commit 4511d05

Browse files
committed
TST: raise nose.SkipTest -> pytest.skip
TST: remove KnownFailure (unused), should be replaced by pytest.xfail anyhow TST: remove nose xref pandas-dev#15341
1 parent 61deba5 commit 4511d05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+388
-477
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,5 +331,5 @@ after_script:
331331
- echo "after_script start"
332332
- ci/install_test.sh
333333
- source activate pandas && python -c "import pandas; pandas.show_versions();"
334-
- ci/print_skipped.py /tmp/nosetests.xml
334+
- ci/print_skipped.py /tmp/pytest.xml
335335
- echo "after_script done"

ci/install_test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ 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 "$TEST_ARGS" pandas/tests/test_series.py --with-xunit --xunit-file=/tmp/nosetests_install.xml
1211
pytest pandas/tests/test_series.py --junitxml=/tmp/pytest_install.xml
1312
else
1413
echo "Skipping installation test."

ci/install_travis.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,7 @@ if [ -e ${INSTALL} ]; then
9292
time bash $INSTALL || exit 1
9393
else
9494
# create new env
95-
time conda create -n pandas python=$PYTHON_VERSION nose pytest || exit 1
96-
97-
if [ "$LINT" ]; then
98-
conda install flake8
99-
pip install cpplint
100-
fi
95+
time conda create -n pandas python=$PYTHON_VERSION pytest || exit 1
10196
fi
10297

10398
# build deps
@@ -116,6 +111,12 @@ fi
116111

117112
source activate pandas
118113

114+
pip install pytest-xdist
115+
if [ "$LINT" ]; then
116+
conda install flake8
117+
pip install cpplint
118+
fi
119+
119120
if [ "$COVERAGE" ]; then
120121
pip install coverage pytest-cov
121122
fi

ci/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if [ "$LINT" ]; then
5555
echo "Linting *.c and *.h DONE"
5656

5757
echo "Check for invalid testing"
58-
grep -r -E --include '*.py' --exclude nosetester.py --exclude testing.py '(numpy|np)\.testing' pandas
58+
grep -r -E --include '*.py' --exclude testing.py '(numpy|np)\.testing' pandas
5959
if [ $? = "0" ]; then
6060
RET=1
6161
fi

ci/requirements_all.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
nose
21
pytest
32
pytest-cov
3+
pytest-xdist
44
flake8
55
sphinx
66
ipython

ci/requirements_dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ python-dateutil
22
pytz
33
numpy
44
cython
5-
nose
65
pytest
76
pytest-cov
7+
pytest-xdist
88
flake8

ci/script.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if [ -n "$LOCALE_OVERRIDE" ]; then
1818
fi
1919

2020
if [ "$BUILD_TEST" ]; then
21-
echo "We are not running nosetests as this is simply a build test."
21+
echo "We are not running pytest as this is simply a build test."
2222
elif [ "$COVERAGE" ]; then
23-
echo pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $TEST_ARGS pandas
24-
pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $TEST_ARGS pandas
23+
echo pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
24+
pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
2525
else
2626
echo pytest $TEST_ARGS pandas
2727
pytest $TEST_ARGS pandas # TODO: doctest

doc/source/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ gbq integration tests on a forked repository:
734734
the status by visiting your Travis branches page which exists at the
735735
following location: https://travis-ci.org/your-user-name/pandas/branches .
736736
Click on a build job for your branch. Expand the following line in the
737-
build log: ``ci/print_skipped.py /tmp/nosetests.xml`` . Search for the
737+
build log: ``ci/print_skipped.py /tmp/pytest.xml`` . Search for the
738738
term ``test_gbq`` and confirm that gbq integration tests are not skipped.
739739

740740
Running the vbench performance test suite (phasing out)

pandas/computation/tests/test_compat.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# flake8: noqa
33

4-
import nose
4+
import pytest
55
from itertools import product
66
from distutils.version import LooseVersion
77

@@ -31,7 +31,7 @@ def test_compat():
3131
assert _NUMEXPR_INSTALLED
3232

3333
except ImportError:
34-
raise nose.SkipTest("not testing numexpr version compat")
34+
pytest.skip("not testing numexpr version compat")
3535

3636

3737
def test_invalid_numexpr_version():
@@ -49,14 +49,14 @@ def testit():
4949
try:
5050
import numexpr as ne
5151
except ImportError:
52-
raise nose.SkipTest("no numexpr")
52+
pytest.skip("no numexpr")
5353
else:
5454
if ne.__version__ < LooseVersion('2.1'):
5555
with tm.assertRaisesRegexp(ImportError, "'numexpr' version is "
5656
".+, must be >= 2.1"):
5757
testit()
5858
elif ne.__version__ == LooseVersion('2.4.4'):
59-
raise nose.SkipTest("numexpr version==2.4.4")
59+
pytest.skip("numexpr version==2.4.4")
6060
else:
6161
testit()
6262
else:

pandas/computation/tests/test_eval.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from itertools import product
77
from distutils.version import LooseVersion
88

9-
import nose
10-
from nose.tools import assert_raises
9+
import pytest
1110

1211
from numpy.random import randn, rand, randint
1312
import numpy as np
@@ -319,7 +318,7 @@ def get_expected_pow_result(self, lhs, rhs):
319318
except ValueError as e:
320319
if str(e).startswith('negative number cannot be raised to a fractional power'):
321320
if self.engine == 'python':
322-
raise nose.SkipTest(str(e))
321+
pytest.skip(str(e))
323322
else:
324323
expected = np.nan
325324
else:
@@ -1174,13 +1173,15 @@ def test_bool_ops_with_constants(self):
11741173
def test_panel_fails(self):
11751174
x = Panel(randn(3, 4, 5))
11761175
y = Series(randn(10))
1177-
assert_raises(NotImplementedError, self.eval, 'x + y',
1176+
with pytest.raises(NotImplementedError):
1177+
self.eval('x + y',
11781178
local_dict={'x': x, 'y': y})
11791179

11801180
def test_4d_ndarray_fails(self):
11811181
x = randn(3, 4, 5, 6)
11821182
y = Series(randn(10))
1183-
assert_raises(NotImplementedError, self.eval, 'x + y',
1183+
with pytest.raises(NotImplementedError):
1184+
self.eval('x + y',
11841185
local_dict={'x': x, 'y': y})
11851186

11861187
def test_constant(self):
@@ -1705,7 +1706,7 @@ def test_result_types(self):
17051706

17061707
def test_result_types2(self):
17071708
# xref https://github.com/pandas-dev/pandas/issues/12293
1708-
raise nose.SkipTest("unreliable tests on complex128")
1709+
pytest.skip("unreliable tests on complex128")
17091710

17101711
# Did not test complex64 because DataFrame is converting it to
17111712
# complex128. Due to https://github.com/pandas-dev/pandas/issues/10952
@@ -1822,7 +1823,8 @@ def check_disallowed_nodes(engine, parser):
18221823
inst = VisitorClass('x + 1', engine, parser)
18231824

18241825
for ops in uns_ops:
1825-
assert_raises(NotImplementedError, getattr(inst, ops))
1826+
with pytest.raises(NotImplementedError):
1827+
getattr(inst, ops)()
18261828

18271829

18281830
def test_disallowed_nodes():
@@ -1833,7 +1835,8 @@ def test_disallowed_nodes():
18331835
def check_syntax_error_exprs(engine, parser):
18341836
tm.skip_if_no_ne(engine)
18351837
e = 's +'
1836-
assert_raises(SyntaxError, pd.eval, e, engine=engine, parser=parser)
1838+
with pytest.raises(SyntaxError):
1839+
pd.eval(e, engine=engine, parser=parser)
18371840

18381841

18391842
def test_syntax_error_exprs():

pandas/io/tests/json/test_pandas.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# pylint: disable-msg=W0612,E1101
3-
import nose
3+
import pytest
44
from pandas.compat import range, lrange, StringIO, OrderedDict
55
import os
66

@@ -1009,8 +1009,8 @@ def test_latin_encoding(self):
10091009
return
10101010

10111011
# GH 13774
1012-
raise nose.SkipTest("encoding not implemented in .to_json(), "
1013-
"xref #13774")
1012+
pytest.skip("encoding not implemented in .to_json(), "
1013+
"xref #13774")
10141014

10151015
values = [[b'E\xc9, 17', b'', b'a', b'b', b'c'],
10161016
[b'E\xc9, 17', b'a', b'b', b'c'],

pandas/io/tests/json/test_ujson.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except ImportError:
88
import simplejson as json
99
import math
10-
import nose
10+
import pytest
1111
import platform
1212
import sys
1313
import time
@@ -28,7 +28,7 @@
2828
def _skip_if_python_ver(skip_major, skip_minor=None):
2929
major, minor = sys.version_info[:2]
3030
if major == skip_major and (skip_minor is None or minor == skip_minor):
31-
raise nose.SkipTest("skipping Python version %d.%d" % (major, minor))
31+
pytest.skip("skipping Python version %d.%d" % (major, minor))
3232

3333

3434
json_unicode = (json.dumps if compat.PY3
@@ -95,7 +95,7 @@ def test_encodeNonCLocale(self):
9595
try:
9696
locale.setlocale(locale.LC_NUMERIC, 'Italian_Italy')
9797
except:
98-
raise nose.SkipTest('Could not set locale for testing')
98+
pytest.skip('Could not set locale for testing')
9999
self.assertEqual(ujson.loads(ujson.dumps(4.78e60)), 4.78e60)
100100
self.assertEqual(ujson.loads('4.78', precise_float=True), 4.78)
101101
locale.setlocale(locale.LC_NUMERIC, savedlocale)
@@ -113,7 +113,7 @@ def test_decimalDecodeTestPrecise(self):
113113

114114
def test_encodeDoubleTinyExponential(self):
115115
if compat.is_platform_windows() and not compat.PY3:
116-
raise nose.SkipTest("buggy on win-64 for py2")
116+
pytest.skip("buggy on win-64 for py2")
117117

118118
num = 1e-40
119119
self.assertEqual(num, ujson.decode(ujson.encode(num)))
@@ -393,8 +393,8 @@ def test_nat(self):
393393
def test_npy_nat(self):
394394
from distutils.version import LooseVersion
395395
if LooseVersion(np.__version__) < '1.7.0':
396-
raise nose.SkipTest("numpy version < 1.7.0, is "
397-
"{0}".format(np.__version__))
396+
pytest.skip("numpy version < 1.7.0, is "
397+
"{0}".format(np.__version__))
398398

399399
input = np.datetime64('NaT')
400400
assert ujson.encode(input) == 'null', "Expected null"

pandas/io/tests/parser/c_parser_only.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
further arguments when parsing.
88
"""
99

10-
import nose
10+
import pytest
1111
import numpy as np
1212

1313
import pandas as pd
@@ -159,7 +159,7 @@ def error(val):
159159

160160
def test_pass_dtype_as_recarray(self):
161161
if compat.is_platform_windows() and self.low_memory:
162-
raise nose.SkipTest(
162+
pytest.skip(
163163
"segfaults on win-64, only when all tests are run")
164164

165165
data = """\

pandas/io/tests/parser/common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
from datetime import datetime
1111

12-
import nose
12+
import pytest
1313
import numpy as np
1414
from pandas.lib import Timestamp
1515

@@ -635,8 +635,8 @@ def test_file(self):
635635
url_table = self.read_table('file://localhost/' + localtable)
636636
except URLError:
637637
# fails on some systems
638-
raise nose.SkipTest("failing on %s" %
639-
' '.join(platform.uname()).strip())
638+
pytest.skip("failing on %s" %
639+
' '.join(platform.uname()).strip())
640640

641641
tm.assert_frame_equal(url_table, local_table)
642642

@@ -1262,7 +1262,7 @@ def test_verbose_import(self):
12621262

12631263
def test_iteration_open_handle(self):
12641264
if PY3:
1265-
raise nose.SkipTest(
1265+
pytest.skip(
12661266
"won't work in Python 3 {0}".format(sys.version_info))
12671267

12681268
with tm.ensure_clean() as path:

pandas/io/tests/parser/compression.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
of the parsers defined in parsers.py
66
"""
77

8-
import nose
8+
import pytest
99

1010
import pandas.util.testing as tm
1111

@@ -16,7 +16,7 @@ def test_zip(self):
1616
try:
1717
import zipfile
1818
except ImportError:
19-
raise nose.SkipTest('need zipfile to run')
19+
pytest.skip('need zipfile to run')
2020

2121
with open(self.csv1, 'rb') as data_file:
2222
data = data_file.read()
@@ -67,7 +67,7 @@ def test_gzip(self):
6767
try:
6868
import gzip
6969
except ImportError:
70-
raise nose.SkipTest('need gzip to run')
70+
pytest.skip('need gzip to run')
7171

7272
with open(self.csv1, 'rb') as data_file:
7373
data = data_file.read()
@@ -96,7 +96,7 @@ def test_bz2(self):
9696
try:
9797
import bz2
9898
except ImportError:
99-
raise nose.SkipTest('need bz2 to run')
99+
pytest.skip('need bz2 to run')
100100

101101
with open(self.csv1, 'rb') as data_file:
102102
data = data_file.read()

pandas/io/tests/parser/converters.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from datetime import datetime
99

10-
import nose
10+
import pytest
1111

1212
import numpy as np
1313
import pandas as pd
@@ -84,8 +84,8 @@ def test_converter_return_string_bug(self):
8484
def test_converters_corner_with_nas(self):
8585
# skip aberration observed on Win64 Python 3.2.2
8686
if hash(np.int64(-1)) != -2:
87-
raise nose.SkipTest("skipping because of windows hash on Python"
88-
" 3.2.2")
87+
pytest.skip("skipping because of windows hash on Python"
88+
" 3.2.2")
8989

9090
data = """id,score,days
9191
1,2,12

pandas/io/tests/parser/parse_dates.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from distutils.version import LooseVersion
99
from datetime import datetime
1010

11-
import nose
11+
import pytest
1212
import numpy as np
1313
import pandas.lib as lib
1414
from pandas.lib import Timestamp
@@ -268,9 +268,9 @@ def test_yy_format_with_yearfirst(self):
268268
# See gh-217
269269
import dateutil
270270
if dateutil.__version__ >= LooseVersion('2.5.0'):
271-
raise nose.SkipTest("testing yearfirst=True not-support"
272-
"on datetutil < 2.5.0 this works but"
273-
"is wrong")
271+
pytest.skip("testing yearfirst=True not-support"
272+
"on datetutil < 2.5.0 this works but"
273+
"is wrong")
274274

275275
rs = self.read_csv(StringIO(data), index_col=0,
276276
parse_dates=[['date', 'time']])

0 commit comments

Comments
 (0)