ó 2ÄÈ[c@`sÎdZddlmZmZmZddlZddlZddlZddlm Z ddl Z ddl m Z mZddd d dd d gZd „Zeed„Zd efd„ƒYZd„ZdS(se Nose test running. This module implements ``test()`` and ``bench()`` functions for NumPy modules. i(tdivisiontabsolute_importtprint_functionN(t basestringi(t import_nosetsuppress_warningstget_package_nametrun_module_suitet NoseTestert _numpy_testerRRcC`s¸|}g}xQd|ks(d|kr`tjj|ƒ\}}|dkrPPn|j|ƒqW|s~d|krwdSdSn|jƒ|djdƒr«|jdƒndj|ƒS( s& 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' s site-packagess dist-packagestscipytnumpyis.eggt.(s site-packagess dist-packages(tostpathtsplittappendtreversetendswithtpoptjoin(tfilepathtfullpathtpkg_nametp2((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyRs   cC`s­|dkrHtjdƒ}|jjddƒ}|dkrHt‚qHn|dkrgtj|g}n ||g}tƒ}ddlm }|j d|d|ƒgƒdS(sÔ Run a test module. Equivalent to calling ``$ nosetests `` 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'. it__file__(tKnownFailurePlugintargvt addpluginsN( tNonetsyst _getframetf_localstgettAssertionErrorRRt noseclassesRtrun(t file_to_runRtftnoseR((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyR@s#      cB`s‰eZdZd dded„Zd„Zd„Zd„Zddd eeed „Z ddd eed ed „Z ddd d „Z RS( sï 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. treleaseicC`s|dkrd}nd}|dkrŽtjd|ƒ}|jjddƒ}|dkrdt‚ntjj|ƒ}|jjddƒ}nKt |t tƒƒrÍtjj|j ƒ}t |ddƒ}n t |ƒ}||_|dkrýt|ƒ}n||_||_||_dS(NR(iRt__name__(RRRR R!R"R Rtdirnamet isinstancettypeRtgetattrtstrt package_pathRt package_nametraise_warningstcheck_fpu_mode(tselftpackageR1tdepthR2R0R&R/((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyt__init__s(          cC`s¤t|jdg}|rj|dkrjt|tƒsBtdƒ‚n|dkrWd}n|d|g7}n|dt|ƒg7}|dg7}|r ||7}n|S( s Generate argv for nosetest command Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional see ``test`` docstring verbose : int, optional Verbosity value for test outputs, in the range 1-10. Default is 1. extra_argv : list, optional List with any extra arguments to pass to nosetests. Returns ------- argv : list command line arguments that will be passed to nose s-stfulls"Selection label should be a stringtfastsnot slows-As --verbositys--exe(RR/R+Rt TypeErrorR.(R3tlabeltverboset extra_argvR((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyt _test_argvÆs    cC`sûtƒ}ddl}td|jƒ|jdddƒjj}td|ƒtjj |j ƒ}td|ƒd |j krÃddl }td |jƒtjj |j ƒ}td |ƒnt jjd d ƒ}td|ƒtd|jƒdS(NisNumPy version %si itordertCs&NumPy relaxed strides checking option:sNumPy is installed in %sR sSciPy version %ssSciPy is installed in %ss tsPython version %ssnose version %d.%d.%d(i i(RR tprintt __version__tonestflagst f_contiguousR RR*RR0R Rtversiontreplacet__versioninfo__(R3R'R trelaxed_stridestnpdirR tspdirt pyversion((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyt_show_system_infoës    cC`sddlm}|ƒS(s» Return instantiated plugin for doctests Allows subclassing of this class to override doctester A return value of None means use the nose builtin doctest plugin i(t NumpyDoctest(R#RN(R3RN((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyt_get_custom_doctesterÿsR8icC`s%tƒ|j|||ƒ}|rB|d|jdddg7}n|r’|tkrd|dg7}q’t|tƒr’|ddt|ƒg7}q’nddl}dd lm } d d l m } m } m } | ƒg} | g|jjjD]}|ƒ^qé7} |jr(| | ƒg7} |d g7}ny7| ƒ}|jƒ| g|jD] }|^qK7} Wntk rrnXd |k}|tkrš|ršt}n|jƒ}|dkrÒ|r| r|d g7}qnI|rè|jd ƒn| | dƒ|g7} |r|d|jg7}n|| fS(sç Run tests for module using nose. This method does the heavy lifting for the `test` method. It takes all the same arguments, for details see `test`. See Also -------- test s--cover-package=%ss--with-coverages --cover-testss --cover-erases --with-timers --timer-top-niN(tEntryPointPluginManageri(Rt UnpluggertFPUModeCheckPlugins--with-fpumodecheckplugins--with-doctesttdoctests--with-(RR=R0tTrueR+tintR.tnose.plugins.builtint nose.pluginsRPR#RRQRRtpluginstbuiltinR2t loadPluginst ImportErrortFalseRORtremovetname(R3R:R;R<tdocteststcoveragettimerRR'RPRRQRRRXtptentrypoint_managert doctest_argvtplug((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pytprepare_test_args sJ   )   $      c C`sËt|dƒ}ddlm}||_|j||||||ƒ\} } |rftd|jƒntd|jƒ|jƒddl} d| _ |dkr®|j }nt dt fd d$ƒ} t|tƒrâ| |}ntd ƒÔ} tjƒtjd ƒx!|D]}tjd d |ƒqW| jddƒ| jddƒ| jddƒ| jd tjƒ| jddƒ| jddƒtjƒ"tjd ƒddlm}WdQX| jd td|ƒtjjdkrttjrtddl }| jt!dd|ƒ| jt!ddƒ| jt!ddƒ| jt!ddƒ| jt!ddƒ| jt!ddƒntjdddd t!ddƒdd l"m#}|d!| d"t$d#| ƒ}WdQX|j%S(%s> Run tests for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional Identifies the tests to run. This can be a string to pass to the nosetests executable with the '-A' option, or one of several special values. Special values are: * 'fast' - the default - which corresponds to the ``nosetests -A`` option of 'not slow'. * 'full' - fast (as above) and slow tests as in the 'no -A' option to nosetests - this is the same as ''. * None or '' - run all tests. attribute_identifier - string passed directly to nosetests as '-A'. verbose : int, optional Verbosity value for test outputs, in the range 1-10. Default is 1. extra_argv : list, optional List with any extra arguments to pass to nosetests. doctests : bool, optional If True, run doctests in module. Default is False. coverage : bool, optional If True, report coverage of NumPy code. Default is False. (This requires the `coverage module: `_). 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. The default is to use the class initialization value. timer : bool or int, optional Timing of individual tests with ``nose-timer`` (which needs to be installed). If True, time tests and report on all of them. If an integer (say ``N``), report timing results for ``N`` slowest tests. Returns ------- result : object Returns the result of running the tests as a ``nose.result.TextTestResult`` object. Notes ----- Each NumPy module exposes `test` in its namespace to run all tests for it. For example, to run all tests for numpy.lib: >>> np.lib.test() #doctest: +SKIP Examples -------- >>> result = np.lib.test() #doctest: +SKIP Running unit tests for numpy.lib ... Ran 976 tests in 3.933s OK >>> result.errors #doctest: +SKIP [] >>> result.knownfail #doctest: +SKIP [] ii(tutilss&Running unit tests and doctests for %ssRunning unit tests for %siNtdevelopR(tlocationtalwaysterrortcategorytmessagesNot importing directorysnumpy.dtype size changedsnumpy.ufunc size changeds.*boolean negative.*s.*boolean subtract.*(tcpuinfotmoduleis(sys\.exc_clear\(\) not supported in 3\.xsin 3\.x, __setslice__sin 3\.x, __getslice__s buffer\(\) not supported in 3\.xs%CObject type is not supported in 3\.xs-comparing unequal types not supported in 3\.xtignores.*getargspec.*snose\.(tNumpyTestProgramRtexitRX((&tminR@RgR;RfRAR0RMRSRtmasterR1tdicttWarningR+RRtwarningst resetwarningstfilterwarningstfiltertnptModuleDeprecationWarningtcatch_warningst simplefiltert distutilsRnt UserWarningRt version_infotmajort py3kwarningt threadingtDeprecationWarningR#RqR\tresult(R3R:R;R<R_R`R1RaRgRRXRSt _warn_optstsupt warningtypeRnR„Rqtt((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyttestIs`G               !cC`s…td|jƒ|jƒ|j|||ƒ}|ddtjg7}tƒ}ddlm}|dƒg}|j d|d|ƒS( sè Run benchmarks for module using nose. Parameters ---------- label : {'fast', 'full', '', attribute identifier}, optional Identifies the benchmarks to run. This can be a string to pass to the nosetests executable with the '-A' option, or one of several special values. Special values are: * 'fast' - the default - which corresponds to the ``nosetests -A`` option of 'not slow'. * 'full' - fast (as above) and slow benchmarks as in the 'no -A' option to nosetests - this is the same as ''. * None or '' - run all tests. attribute_identifier - string passed directly to nosetests as '-A'. verbose : int, optional Verbosity value for benchmark outputs, in the range 1-10. Default is 1. extra_argv : list, optional List with any extra arguments to pass to nosetests. Returns ------- success : bool Returns True if running the benchmarks works, False if an error occurred. Notes ----- Benchmarks are like tests, but have names starting with "bench" instead of "test", and can be found under the "benchmarks" sub-directory of the module. Each NumPy module exposes `bench` in its namespace to run all benchmarks for it. Examples -------- >>> success = np.lib.bench() #doctest: +SKIP Running benchmarks for numpy.lib ... using 562341 items: unique: 0.11 unique1d: 0.11 ratio: 1.0 nUnique: 56230 == 56230 ... OK >>> success #doctest: +SKIP True sRunning benchmarks for %ss--matchs(?:^|[\\b_\\.%s-])[Bb]enchi(RQRSRR( RAR0RMR=R tsepRR#RQR$(R3R:R;R<RR'RQt add_plugins((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pytbenchâs8  N( R)t __module__t__doc__RR\R6R=RMRORfR‹RŽ(((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyRss)  ( %  ?   —cC`sFttdƒr'dtjkr'd}nd}td|dddtƒS( NRBs.dev0RhR(R1R5iR2(thasattrR{RBRRT(tmode((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyR *s  (Rt __future__RRRR RRwt numpy.compatRR R{RgRRt__all__RRRtobjectRR (((s@/tmp/pip-build-fiC0ax/numpy/numpy/testing/_private/nosetester.pyts        )3ÿ¸