Skip to content

Commit

Permalink
TST: Update modules test to PytestTester.
Browse files Browse the repository at this point in the history
Numpy can now be tested using the standard

    `python -c"import numpy; numpy.test()"`

construct.
  • Loading branch information
charris committed Apr 4, 2018
1 parent 7e5a41d commit cf46d8c
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 35 deletions.
20 changes: 9 additions & 11 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ def pkgload(*packages, **options):

pkgload.__doc__ = PackageLoader.__call__.__doc__

# We don't actually use this ourselves anymore, but I'm not 100% sure that
# no-one else in the world is using it (though I hope not)
from .testing import Tester, _numpy_tester
test = _numpy_tester().test

# Allow distributors to run custom init code
from . import _distributor_init

Expand Down Expand Up @@ -186,13 +181,16 @@ def pkgload(*packages, **options):
__all__.extend(lib.__all__)
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])


# Filter annoying Cython warnings that serve no good purpose.
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
warnings.filterwarnings("ignore", message="numpy.ndarray size changed")

# oldnumeric and numarray were removed in 1.9. In case some packages import
# but do not use them, we define them here for backward compatibility.
oldnumeric = 'removed'
numarray = 'removed'

# We don't actually use this ourselves anymore, but I'm not 100% sure that
# no-one else in the world is using it (though I hope not)
from .testing import Tester

# Pytest testing
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
8 changes: 4 additions & 4 deletions numpy/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@
__all__ += shape_base.__all__
__all__ += einsumfunc.__all__


from numpy.testing import _numpy_tester
test = _numpy_tester().test

# Make it possible so that ufuncs can be pickled
# Here are the loading and unloading functions
# The name numpy.core._ufunc_reconstruct must be
Expand Down Expand Up @@ -103,3 +99,7 @@ def _ufunc_reduce(func):
del copyreg
del sys
del _ufunc_reduce

from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/distutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
# Normally numpy is installed if the above import works, but an interrupted
# in-place build could also have left a __config__.py. In that case the
# next import may still fail, so keep it inside the try block.
from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
except ImportError:
pass

Expand Down
5 changes: 3 additions & 2 deletions numpy/f2py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ def compile(source,
f.close()
return status

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/fft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
from .fftpack import *
from .helper import *

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
__all__ += nanfunctions.__all__
__all__ += histograms.__all__

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@

from .linalg import *

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/ma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
__all__ += core.__all__
__all__ += extras.__all__

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/matrixlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

__all__ = defmatrix.__all__

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/polynomial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
from .hermite_e import HermiteE
from .laguerre import Laguerre

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
5 changes: 3 additions & 2 deletions numpy/random/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ def __RandomState_ctor():
"""
return RandomState(seed=0)

from numpy.testing import _numpy_tester
test = _numpy_tester().test
from numpy.testing._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
6 changes: 4 additions & 2 deletions numpy/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
from ._private.utils import *
from ._private import decorators as dec
from ._private.nosetester import (
run_module_suite, NoseTester as Tester, _numpy_tester,
run_module_suite, NoseTester as Tester
)

__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']

test = _numpy_tester().test
from ._private.pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester

0 comments on commit cf46d8c

Please sign in to comment.