관리-도구
편집 파일: nosetester.cpython-37.pyc
B ��Fd�J � @ s� d Z ddlmZmZmZ ddlZddlZddlZddlm Z ddl Zddlm Z mZ dd� Zdd d �ZG dd� de�Zd d� ZdS )ze Nose test running. This module implements ``test()`` and ``bench()`` functions for NumPy modules. � )�division�absolute_import�print_functionN)� basestring� )�import_nose�suppress_warningsc C s� | dd� }g }x8d| ks"d| krHt j�| �\} }|dkr<P |�|� qW |s^d|krZdS dS |�� |d �d�r~|�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-packages�scipy�numpyr z.egg�.)�os�path�split�append�reverse�endswith�pop�join)�filepath�fullpath�pkg_name�p2� r �K/opt/alt/python37/lib64/python3.7/site-packages/numpy/testing/nosetester.py�get_package_name s r c C st | dkr,t �d�}|j�dd�} | 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� _getframe�f_locals�get�AssertionErrorr r �noseclassesr �run)Zfile_to_runr �f�noser r r r �run_module_suite; s # r( c @ sP e Zd ZdZddd�Zdd� Zd d � Zdd� Zddd�Zddd�Z ddd�Z 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. N�releaser c C s� |d krd}d }|d kr\t �d| �}|j�dd �}|d kr@t�tj�|�}|j�dd �}n2t|t t��r�tj�|j �}t|dd �}nt|�}|| _ |d kr�t|�}|| _|| _d S )Nr* r r �__name__)r r r! r"