Skip to content

Commit

Permalink
TST: remove nose
Browse files Browse the repository at this point in the history
TST: raise nose.SkipTest -> pytest.skip  TST: remove KnownFailure
(unused), should be replaced by pytest.xfail anyhow    xref pandas-dev#15341

Author: Jeff Reback <[email protected]>

Closes pandas-dev#15368 from jreback/skip and squashes the following commits:

afdb5f9 [Jeff Reback] TST: raise nose.SkipTest -> pytest.skip
  • Loading branch information
jreback authored and AnkurDedania committed Mar 21, 2017
1 parent a4e8018 commit 5dabbaf
Show file tree
Hide file tree
Showing 71 changed files with 389 additions and 522 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,5 @@ after_script:
- echo "after_script start"
- ci/install_test.sh
- source activate pandas && python -c "import pandas; pandas.show_versions();"
- ci/print_skipped.py /tmp/nosetests.xml
- ci/print_skipped.py /tmp/pytest.xml
- echo "after_script done"
1 change: 0 additions & 1 deletion ci/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if [ "$INSTALL_TEST" ]; then
conda uninstall cython || exit 1
python "$TRAVIS_BUILD_DIR"/setup.py sdist --formats=zip,gztar || exit 1
pip install "$TRAVIS_BUILD_DIR"/dist/*tar.gz || exit 1
# nosetests --exe -A "$TEST_ARGS" pandas/tests/test_series.py --with-xunit --xunit-file=/tmp/nosetests_install.xml
pytest pandas/tests/test_series.py --junitxml=/tmp/pytest_install.xml
else
echo "Skipping installation test."
Expand Down
13 changes: 7 additions & 6 deletions ci/install_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ if [ -e ${INSTALL} ]; then
time bash $INSTALL || exit 1
else
# create new env
time conda create -n pandas python=$PYTHON_VERSION nose pytest || exit 1

if [ "$LINT" ]; then
conda install flake8
pip install cpplint
fi
time conda create -n pandas python=$PYTHON_VERSION pytest || exit 1
fi

# build deps
Expand All @@ -116,6 +111,12 @@ fi

source activate pandas

pip install pytest-xdist
if [ "$LINT" ]; then
conda install flake8
pip install cpplint
fi

if [ "$COVERAGE" ]; then
pip install coverage pytest-cov
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if [ "$LINT" ]; then
echo "Linting *.c and *.h DONE"

echo "Check for invalid testing"
grep -r -E --include '*.py' --exclude nosetester.py --exclude testing.py '(numpy|np)\.testing' pandas
grep -r -E --include '*.py' --exclude testing.py '(numpy|np)\.testing' pandas
if [ $? = "0" ]; then
RET=1
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements_all.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nose
pytest
pytest-cov
pytest-xdist
flake8
sphinx
ipython
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ python-dateutil
pytz
numpy
cython
nose
pytest
pytest-cov
pytest-xdist
flake8
6 changes: 3 additions & 3 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ if [ -n "$LOCALE_OVERRIDE" ]; then
fi

if [ "$BUILD_TEST" ]; then
echo "We are not running nosetests as this is simply a build test."
echo "We are not running pytest as this is simply a build test."
elif [ "$COVERAGE" ]; then
echo pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $TEST_ARGS pandas
pytest -s --cov=pandas --cov-report xml:/tmp/nosetests.xml $TEST_ARGS pandas
echo pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
pytest -s --cov=pandas --cov-report xml:/tmp/pytest.xml $TEST_ARGS pandas
else
echo pytest $TEST_ARGS pandas
pytest $TEST_ARGS pandas # TODO: doctest
Expand Down
2 changes: 1 addition & 1 deletion doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ gbq integration tests on a forked repository:
the status by visiting your Travis branches page which exists at the
following location: https://travis-ci.org/your-user-name/pandas/branches .
Click on a build job for your branch. Expand the following line in the
build log: ``ci/print_skipped.py /tmp/nosetests.xml`` . Search for the
build log: ``ci/print_skipped.py /tmp/pytest.xml`` . Search for the
term ``test_gbq`` and confirm that gbq integration tests are not skipped.

Running the vbench performance test suite (phasing out)
Expand Down
8 changes: 4 additions & 4 deletions pandas/computation/tests/test_compat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# flake8: noqa

import nose
import pytest
from itertools import product
from distutils.version import LooseVersion

Expand Down Expand Up @@ -31,7 +31,7 @@ def test_compat():
assert _NUMEXPR_INSTALLED

except ImportError:
raise nose.SkipTest("not testing numexpr version compat")
pytest.skip("not testing numexpr version compat")


def test_invalid_numexpr_version():
Expand All @@ -49,14 +49,14 @@ def testit():
try:
import numexpr as ne
except ImportError:
raise nose.SkipTest("no numexpr")
pytest.skip("no numexpr")
else:
if ne.__version__ < LooseVersion('2.1'):
with tm.assertRaisesRegexp(ImportError, "'numexpr' version is "
".+, must be >= 2.1"):
testit()
elif ne.__version__ == LooseVersion('2.4.4'):
raise nose.SkipTest("numexpr version==2.4.4")
pytest.skip("numexpr version==2.4.4")
else:
testit()
else:
Expand Down
19 changes: 11 additions & 8 deletions pandas/computation/tests/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from itertools import product
from distutils.version import LooseVersion

import nose
from nose.tools import assert_raises
import pytest

from numpy.random import randn, rand, randint
import numpy as np
Expand Down Expand Up @@ -319,7 +318,7 @@ def get_expected_pow_result(self, lhs, rhs):
except ValueError as e:
if str(e).startswith('negative number cannot be raised to a fractional power'):
if self.engine == 'python':
raise nose.SkipTest(str(e))
pytest.skip(str(e))
else:
expected = np.nan
else:
Expand Down Expand Up @@ -1174,13 +1173,15 @@ def test_bool_ops_with_constants(self):
def test_panel_fails(self):
x = Panel(randn(3, 4, 5))
y = Series(randn(10))
assert_raises(NotImplementedError, self.eval, 'x + y',
with pytest.raises(NotImplementedError):
self.eval('x + y',
local_dict={'x': x, 'y': y})

def test_4d_ndarray_fails(self):
x = randn(3, 4, 5, 6)
y = Series(randn(10))
assert_raises(NotImplementedError, self.eval, 'x + y',
with pytest.raises(NotImplementedError):
self.eval('x + y',
local_dict={'x': x, 'y': y})

def test_constant(self):
Expand Down Expand Up @@ -1705,7 +1706,7 @@ def test_result_types(self):

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

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

for ops in uns_ops:
assert_raises(NotImplementedError, getattr(inst, ops))
with pytest.raises(NotImplementedError):
getattr(inst, ops)()


def test_disallowed_nodes():
Expand All @@ -1833,7 +1835,8 @@ def test_disallowed_nodes():
def check_syntax_error_exprs(engine, parser):
tm.skip_if_no_ne(engine)
e = 's +'
assert_raises(SyntaxError, pd.eval, e, engine=engine, parser=parser)
with pytest.raises(SyntaxError):
pd.eval(e, engine=engine, parser=parser)


def test_syntax_error_exprs():
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/tests/json/test_pandas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable-msg=W0612,E1101
import nose
import pytest
from pandas.compat import range, lrange, StringIO, OrderedDict
import os

Expand Down Expand Up @@ -1009,8 +1009,8 @@ def test_latin_encoding(self):
return

# GH 13774
raise nose.SkipTest("encoding not implemented in .to_json(), "
"xref #13774")
pytest.skip("encoding not implemented in .to_json(), "
"xref #13774")

values = [[b'E\xc9, 17', b'', b'a', b'b', b'c'],
[b'E\xc9, 17', b'a', b'b', b'c'],
Expand Down
12 changes: 6 additions & 6 deletions pandas/io/tests/json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
except ImportError:
import simplejson as json
import math
import nose
import pytest
import platform
import sys
import time
Expand All @@ -28,7 +28,7 @@
def _skip_if_python_ver(skip_major, skip_minor=None):
major, minor = sys.version_info[:2]
if major == skip_major and (skip_minor is None or minor == skip_minor):
raise nose.SkipTest("skipping Python version %d.%d" % (major, minor))
pytest.skip("skipping Python version %d.%d" % (major, minor))


json_unicode = (json.dumps if compat.PY3
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_encodeNonCLocale(self):
try:
locale.setlocale(locale.LC_NUMERIC, 'Italian_Italy')
except:
raise nose.SkipTest('Could not set locale for testing')
pytest.skip('Could not set locale for testing')
self.assertEqual(ujson.loads(ujson.dumps(4.78e60)), 4.78e60)
self.assertEqual(ujson.loads('4.78', precise_float=True), 4.78)
locale.setlocale(locale.LC_NUMERIC, savedlocale)
Expand All @@ -113,7 +113,7 @@ def test_decimalDecodeTestPrecise(self):

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

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

input = np.datetime64('NaT')
assert ujson.encode(input) == 'null', "Expected null"
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/tests/parser/c_parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
further arguments when parsing.
"""

import nose
import pytest
import numpy as np

import pandas as pd
Expand Down Expand Up @@ -159,7 +159,7 @@ def error(val):

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

data = """\
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/tests/parser/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
from datetime import datetime

import nose
import pytest
import numpy as np
from pandas.lib import Timestamp

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

tm.assert_frame_equal(url_table, local_table)

Expand Down Expand Up @@ -1262,7 +1262,7 @@ def test_verbose_import(self):

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

with tm.ensure_clean() as path:
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/tests/parser/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
of the parsers defined in parsers.py
"""

import nose
import pytest

import pandas.util.testing as tm

Expand All @@ -16,7 +16,7 @@ def test_zip(self):
try:
import zipfile
except ImportError:
raise nose.SkipTest('need zipfile to run')
pytest.skip('need zipfile to run')

with open(self.csv1, 'rb') as data_file:
data = data_file.read()
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_gzip(self):
try:
import gzip
except ImportError:
raise nose.SkipTest('need gzip to run')
pytest.skip('need gzip to run')

with open(self.csv1, 'rb') as data_file:
data = data_file.read()
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_bz2(self):
try:
import bz2
except ImportError:
raise nose.SkipTest('need bz2 to run')
pytest.skip('need bz2 to run')

with open(self.csv1, 'rb') as data_file:
data = data_file.read()
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/tests/parser/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from datetime import datetime

import nose
import pytest

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

data = """id,score,days
1,2,12
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/tests/parser/parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from distutils.version import LooseVersion
from datetime import datetime

import nose
import pytest
import numpy as np
import pandas.lib as lib
from pandas.lib import Timestamp
Expand Down Expand Up @@ -268,9 +268,9 @@ def test_yy_format_with_yearfirst(self):
# See gh-217
import dateutil
if dateutil.__version__ >= LooseVersion('2.5.0'):
raise nose.SkipTest("testing yearfirst=True not-support"
"on datetutil < 2.5.0 this works but"
"is wrong")
pytest.skip("testing yearfirst=True not-support"
"on datetutil < 2.5.0 this works but"
"is wrong")

rs = self.read_csv(StringIO(data), index_col=0,
parse_dates=[['date', 'time']])
Expand Down
Loading

0 comments on commit 5dabbaf

Please sign in to comment.