B
<FdJ @ s d Z ddlmZmZmZ ddlZddlZddlZddlm Z ddl
Zddlm
Z
mZ dd Zdd d
ZG dd deZd
d ZdS )ze
Nose test running.
This module implements ``test()`` and ``bench()`` functions for NumPy modules.
)divisionabsolute_importprint_functionN)
basestring )import_nosesuppress_warningsc C s | dd }g }x8d| ks"d| krHt j| \} }|dkr<P || qW |s^d|krZdS dS | |d dr~|d d |S )
a&
Given a path where a package is installed, determine its name.
Parameters
----------
filepath : str
Path to a file. If the determination fails, "numpy" is returned.
Examples
--------
>>> np.testing.nosetester.get_package_name('nonsense')
'numpy'
Nz
site-packagesz
dist-packages)z
site-packagesz
dist-packagesscipynumpyr z.egg.)ospathsplitappendreverseendswithpopjoin)filepathZfullpathZpkg_nameZp2 r K/opt/alt/python37/lib64/python3.7/site-packages/numpy/testing/nosetester.pyget_package_name s
r c C st | dkr,t d}|jdd} | dkr,t|dkrBt j| g }n
|| g }t }ddlm} |j || gd dS )a
Run a test module.
Equivalent to calling ``$ nosetests <argv> <file_to_run>`` from
the command line
Parameters
----------
file_to_run : str, optional
Path to test module, or None.
By default, run the module from which this function is called.
argv : list of strings
Arguments to be passed to the nose test runner. ``argv[0]`` is
ignored. All command line arguments accepted by ``nosetests``
will work. If it is the default value None, sys.argv is used.
.. versionadded:: 1.9.0
Examples
--------
Adding the following::
if __name__ == "__main__" :
run_module_suite(argv=sys.argv)
at the end of a test module will run the tests when that module is
called in the python interpreter.
Alternatively, calling::
>>> run_module_suite(file_to_run="numpy/tests/test_matlib.py")
from an interpreter will run all the test routine in 'test_matlib.py'.
Nr __file__)KnownFailurePlugin)argv
addplugins)
sys _getframef_localsgetAssertionErrorr r noseclassesr run)Zfile_to_runr fnoser r r r run_module_suite; s #
r% c @ sP e Zd ZdZdddZdd Zd d
Zdd ZdddZdddZ dddZ
dS )
NoseTestera
Nose test runner.
This class is made available as numpy.testing.Tester, and a test function
is typically added to a package's __init__.py like so::
from numpy.testing import Tester
test = Tester().test
Calling this test function finds and runs all tests associated with the
package and all its sub-packages.
Attributes
----------
package_path : str
Full path to the package to test.
package_name : str
Name of the package to test.
Parameters
----------
package : module, str or None, optional
The package to test. If a string, this should be the full path to
the package. If None (default), `package` is set to the module from
which `NoseTester` is initialized.
raise_warnings : None, str or sequence of warnings, optional
This specifies which warnings to configure as 'raise' instead
of being shown once during the test execution. Valid strings are:
- "develop" : equals ``(Warning,)``
- "release" : equals ``()``, don't raise on any warnings.
Default is "release".
depth : int, optional
If `package` is None, then this can be used to initialize from the
module of the caller of (the caller of (...)) the code that
initializes `NoseTester`. Default of 0 means the module of the
immediate caller; higher values are useful for utility routines that
want to initialize `NoseTester` objects on behalf of other code.
Nreleaser c C s |d krd}d }|d kr\t d| }|jdd }|d kr@ttj|}|jdd }n2t|t trtj|j
}t|dd }nt|}|| _
|d krt|}|| _|| _d S )Nr'