diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-03-25 12:34:16 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2018-04-04 06:36:36 -0600 |
commit | 7e5a41de9fab731e27a761c01302a0a93e2d1070 (patch) | |
tree | dbd6265800ad401476bcde904e9bba86f6af2b85 /numpy/tests | |
parent | 359e53ef8e479eefac0e184d4d25af50c2779ce0 (diff) | |
download | numpy-7e5a41de9fab731e27a761c01302a0a93e2d1070.tar.gz |
TST: Switch to using pytest markers
Use standard pytest markers everywhere in the numpy tests. At this point
there should be no nose dependency. However, nose is required to test
the legacy decorators if so desired.
At this point, numpy test cannot be run in the way with runtests, rather
installed numpy can be tested with `pytest --pyargs numpy` as long as
that is not run from the repo. Run it from the tools directory or some
such.
Diffstat (limited to 'numpy/tests')
-rw-r--r-- | numpy/tests/test_ctypeslib.py | 19 | ||||
-rw-r--r-- | numpy/tests/test_scripts.py | 9 | ||||
-rw-r--r-- | numpy/tests/test_warnings.py | 9 |
3 files changed, 19 insertions, 18 deletions
diff --git a/numpy/tests/test_ctypeslib.py b/numpy/tests/test_ctypeslib.py index e8043d057..a208c9073 100644 --- a/numpy/tests/test_ctypeslib.py +++ b/numpy/tests/test_ctypeslib.py @@ -1,11 +1,12 @@ from __future__ import division, absolute_import, print_function import sys +import pytest import numpy as np from numpy.ctypeslib import ndpointer, load_library from numpy.distutils.misc_util import get_shared_lib_extension -from numpy.testing import run_module_suite, assert_, assert_raises, dec +from numpy.testing import run_module_suite, assert_, assert_raises try: cdll = None @@ -21,10 +22,10 @@ except ImportError: _HAS_CTYPE = False class TestLoadLibrary(object): - @dec.skipif(not _HAS_CTYPE, - "ctypes not available on this python installation") - @dec.knownfailureif(sys.platform == - 'cygwin', "This test is known to fail on cygwin") + @pytest.mark.skipif(not _HAS_CTYPE, + reason="ctypes not available in this python") + @pytest.mark.skipif(sys.platform == 'cygwin', + reason="Known to fail on cygwin") def test_basic(self): try: # Should succeed @@ -34,10 +35,10 @@ class TestLoadLibrary(object): " (import error was: %s)" % str(e)) print(msg) - @dec.skipif(not _HAS_CTYPE, - "ctypes not available on this python installation") - @dec.knownfailureif(sys.platform == - 'cygwin', "This test is known to fail on cygwin") + @pytest.mark.skipif(not _HAS_CTYPE, + reason="ctypes not available in this python") + @pytest.mark.skipif(sys.platform == 'cygwin', + reason="Known to fail on cygwin") def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. diff --git a/numpy/tests/test_scripts.py b/numpy/tests/test_scripts.py index 675fe6575..ee09390c7 100644 --- a/numpy/tests/test_scripts.py +++ b/numpy/tests/test_scripts.py @@ -4,14 +4,15 @@ Test that we can run executable scripts that have been installed with numpy. """ from __future__ import division, print_function, absolute_import +import sys import os +import pytest from os.path import join as pathjoin, isfile, dirname, basename -import sys from subprocess import Popen, PIPE + import numpy as np from numpy.compat.py3k import basestring -from nose.tools import assert_equal -from numpy.testing import assert_, dec +from numpy.testing import assert_, assert_equal is_inplace = isfile(pathjoin(dirname(np.__file__), '..', 'setup.py')) @@ -58,7 +59,7 @@ def run_command(cmd, check_code=True): return proc.returncode, stdout, stderr -@dec.skipif(is_inplace) +@pytest.mark.skipif(is_inplace, reason="Cannot test f2py command inplace") def test_f2py(): # test that we can run f2py script if sys.platform == 'win32': diff --git a/numpy/tests/test_warnings.py b/numpy/tests/test_warnings.py index 7f22794ec..abebdafc8 100644 --- a/numpy/tests/test_warnings.py +++ b/numpy/tests/test_warnings.py @@ -2,18 +2,17 @@ Tests which scan for certain occurrences in the code, they may not find all of these occurrences but should catch almost all. """ - - from __future__ import division, absolute_import, print_function - import sys +import pytest + if sys.version_info >= (3, 4): from pathlib import Path import ast import tokenize import numpy - from numpy.testing import run_module_suite, dec + from numpy.testing import run_module_suite class ParseCall(ast.NodeVisitor): def __init__(self): @@ -61,7 +60,7 @@ if sys.version_info >= (3, 4): "{} on line {}".format(self.__filename, node.lineno)) - @dec.slow + @pytest.mark.slow def test_warning_calls(): # combined "ignore" and stacklevel error base = Path(numpy.__file__).parent |