Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
numpy
/
testing
/
__pycache__
/
File Content:
nosetester.cpython-35.opt-1.pyc
X��f�G � @ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d � Z d d � Z d d d d � Z Gd d � d e � Z d d � Z d S)ze Nose test running. This module implements ``test()`` and ``bench()`` functions for NumPy modules. � )�division�absolute_import�print_functionN)� basestringc C s� | d d � } g } xN d | k s1 d | k rf t j j | � \ } } | d k rV P| j | � q W| s� d | k r} d Sd S| j � | d j d � r� | j d � d j | � 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' N� site-packages� dist-packages�scipy�numpyr z.egg�.)r r )�os�path�split�append�reverse�endswith�pop�join)�filepathZfullpathZpkg_nameZp2� r �/nosetester.py�get_package_name s r c C sl d } d } y d d l } Wn t k r6 d } Yn X| j | k rL d } | sh d | } t | � � | S)z# Import nose only when needed. T� r NFzWNeed nose >= %d.%d.%d for tests - see http://somethingaboutorange.com/mrl/projects/nose)r r r )�nose�ImportError�__versioninfo__)Z fine_noseZminimum_nose_versionr �msgr r r �import_nose8 s r c C s� | d k rB t j d � } | j j d d � } | d k rB t � | d k ra t j | g } n | | g } t � } d d l m } | j d | d | � g � d S)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� _getframe�f_locals�get�AssertionErrorr r �noseclassesr �run)Zfile_to_runr �fr r r r r �run_module_suiteM s # r) c @ s� e Z d Z d Z d d d d d � Z d d � Z d d � Z d d � Z d d d d d d d � Z d d d d d d d d � Z d d d d d � Z d S)� 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 'warn' during the test execution. Valid strings are: - "develop" : equals ``(DeprecationWarning, RuntimeWarning)`` - "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. N�releaser c C s | d k r d } d } | d k r� t j d | � } | j j d d � } | d k r^ t � t j j | � } | j j d d � } nK t | t t � � r� t j j | j � } t | d d � } n t | � } | | _ | d k r� t | � } | | _ | | _ d S)Nr+ r r �__name__)r! r"