Current File : //lib/python2.7/site-packages/nose/core.pyc
�
d�Uc@swdZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZmZmZddlmZddlmZdd	lmZmZejd
�ZejdkZd
ddddddgZdejfd��YZd
ejfd��YZeZZ d�Z!dd�Z"d�Z#e$dkrse �ndS(s,Implements nose test program and collector.
i����(t
generatorsN(tConfigtall_config_files(tdefaultTestLoader(t
PluginManagertDefaultPluginManagertRestrictedPluginManager(tTextTestResult(tFinalizingSuiteWrapper(tisclassttolists	nose.coreiitTestProgramtmaintruntrun_exitt	runmodulet	collectortTextTestRunnercBs8eZdZejdddd�Zd�Zd�ZRS(s�Test runner that uses nose's TextTestResult to enable errorClasses,
    as well as providing hooks for plugins to override or replace the test
    output stream, results, and the test case itself.
    icCs>|dkrt�}n||_tjj||||�dS(N(tNoneRtconfigtunittestRt__init__(tselftstreamtdescriptionst	verbosityR((s-/usr/lib/python2.7/site-packages/nose/core.pyR s	cCst|j|j|j|j�S(N(RRRRR(R((s-/usr/lib/python2.7/site-packages/nose/core.pyt_makeResult(s	cCs�|jjj|�}|dk	r*|}n|jjj|j�}|dk	rZ||_n|j�}tj�}y||�Wntk
r�nXtj�}|j	�|j
||�|jjj|�|S(saOverrides to provide plugin hooks and defer all output to
        the test result class.
        N(RtpluginstprepareTestRtsetOutputStreamRRttimetKeyboardInterrupttprintErrorstprintSummarytfinalize(Rttesttwrappertwrappedtresulttstarttstop((s-/usr/lib/python2.7/site-packages/nose/core.pyR
.s"	

N(	t__name__t
__module__t__doc__tsyststderrRRRR
(((s-/usr/lib/python2.7/site-packages/nose/core.pyRs
	cBs�eZdZdZddddddddeddd�Zdd�Zdd�Zd�Z	d�Z
d�Zd	�Zd
�Z
ee
�Z
RS(s�Collect and run tests, returning success or failure.

    The arguments to TestProgram() are the same as to
    :func:`main()` and :func:`run()`:

    * module: All tests are in this module (default: None)
    * defaultTest: Tests to load (default: '.')
    * argv: Command line arguments (default: None; sys.argv is read)
    * testRunner: Test runner instance (default: None)
    * testLoader: Test loader instance (default: None)
    * env: Environment; ignored if config is provided (default: None;
      os.environ is read)
    * config: :class:`nose.config.Config` instance (default: None)
    * suite: Suite or list of tests to run (default: None). Passing a
      suite or lists of tests will bypass all test discovery and
      loading. *ALSO NOTE* that if you pass a unittest.TestSuite
      instance as the suite, context fixtures at the class, module and
      package level will not be used, and many plugin hooks will not
      be called. If you want normal nose behavior, either pass a list
      of tests, or a fully-configured :class:`nose.suite.ContextSuite`.
    * exit: Exit after running tests and printing report (default: True)
    * plugins: List of plugins to use; ignored if config is provided
      (default: load plugins with DefaultPluginManager)
    * addplugins: List of **extra** plugins to use. Pass a list of plugin
      instances in this argument to make custom plugins available while
      still using the DefaultPluginManager.
    it.cCs�|dkrtj}n|dkr9|j||
�}n|rU|jjd|�n||_||_|	|_i}t	j
dd!}
|
dkr�|
d
kr�|	|d<ntjj
|d|d|d	|d
|d||�dS(NtextrapluginsiiiitexittmoduletdefaultTesttargvt
testRunnert
testLoader(ii(ii(Rtostenviront
makeConfigRt
addPluginsRtsuiteR0R,tversion_infoRRR(RR1R2R3R4R5tenvRR:R0Rt
addpluginst
extra_argstversion((s-/usr/lib/python2.7/site-packages/nose/core.pyRfs"			
	cCs-|p	i}|jdt�r"gSt�SdS(NtNOSE_IGNORE_CONFIG_FILES(tgettFalseR(RR<((s-/usr/lib/python2.7/site-packages/nose/core.pytgetAllConfigFiles{scCsI|j|�}|r'td|�}n	t�}td|d|d|�S(sSLoad a Config, pre-filled with user config files if any are
        found.
        RR<tfiles(RCRRR(RR<Rt	cfg_filestmanager((s-/usr/lib/python2.7/site-packages/nose/core.pyR8�s	cCs�|jj|d|j��tjd|j�|jjjr�ddlm}t	j
t	_dtj
jt	jd�|fGHt	jd�n|jjjr�|j�t	jd�n|jdkr�td|j�|_n*t|j�r|jd|j�|_n|jjj|j�}|dk	r6||_ntjd|j�|jjrg|jj|_nt|j�|_tjd	|j�tjd
|j�|jjdk	r�tj|jj�n|j�dS(s>Parse argv and env and configure running environment.
        tdocs
configured %si����(t__version__s
%s version %siRstest loader is %ssdefaultTest %ssTest names are %sN(Rt	configuretusagetlogtdebugtoptionsR?tnoseRHR,t
__stdout__tstdoutR6tpathtbasenameR3R0tshowPluginsR5RRR	RtprepareTestLoadert	testNamesR
R2t
workingDirtchdirtcreateTests(RR3RHtplug_loader((s-/usr/lib/python2.7/site-packages/nose/core.pyt	parseArgs�s4"
cCsYtjd|j�|jdk	r=|jj|j�|_n|jj|j�|_dS(s�Create the tests to run. If a self.suite
        is set, then that suite will be used. Otherwise, tests will be
        loaded from the given test names (self.testNames) using the
        test loader.
        screateTests called with %sN(	RKRLR:RR5t
suiteClassR#tloadTestsFromNamesRU(R((s-/usr/lib/python2.7/site-packages/nose/core.pyRX�scCs�tjd�|jdkrLtd|jjd|jjd|j�|_n|jjj	|j�}|dk	r|||_n|jj
|j�}|j�|_
|jr�tj|j
�n|j
S(soRun Tests. Returns true on success, false on failure, and sets
        self.success to the same value.
        srunTests calledRRRN(RKRLR4RRRRRRtprepareTestRunnerR
R#t
wasSuccessfultsuccessR0R,(Rtplug_runnerR&((s-/usr/lib/python2.7/site-packages/nose/core.pytrunTests�s
	c	CsHddl}ddd��Y}|jj}|jjj�x|jjD]�}d|jGH|dkrHd|jGHdj|j|j	�j
�d	d
dd
��GH|dkr<|�}|j|�t|j
�r<Hd
GHx^|j
D]P\}}ddj|�GH|r�dj|j|j
�d	ddd��GHq�q�Wq<nHqHqHWdS(s)Print list of available plugins.
        i����NtDummyParsercBseZd�Zd�ZRS(cSs
g|_dS(N(RM(R((s-/usr/lib/python2.7/site-packages/nose/core.pyR�sc_s&|jj||jdd�f�dS(Nthelpt(RMtappendtpop(Rtargtkw((s-/usr/lib/python2.7/site-packages/nose/core.pyt
add_option�s(R)R*RRi(((s-/usr/lib/python2.7/site-packages/nose/core.pyRb�s	s	Plugin %sis  score: %ss
tinitial_indents  tsubsequent_indentis
  Options:s  %ss, s    ((ttextwrapRRRtsorttnametscoretjointwrapRctstript
addOptionstlenRM(RRlRbtvtptparsertoptsRc((s-/usr/lib/python2.7/site-packages/nose/core.pyRS�s2	
cCs�ddl}y7|j}|jtjjtjjt�d��}WnYtk
r�t	tjjtjjt�d�d�}z|j
�}Wd|j�XnXt|t
�s�|jd�}n|S(Ni����s	usage.txttrsutf-8(RNt
__loader__tget_dataR6RQRptdirnamet__file__tAttributeErrortopentreadtcloset
isinstancetstrtdecode(tclsRNtldttexttf((s-/usr/lib/python2.7/site-packages/nose/core.pyRJ�s	
N(R)R*R+RRtTrueRRCR8RZRXRaRSRJtclassmethod(((s-/usr/lib/python2.7/site-packages/nose/core.pyRHs		'			#	cOst|d<t||�jS(s�Collect and run tests, returning success or failure.

    The arguments to `run()` are the same as to `main()`:

    * module: All tests are in this module (default: None)
    * defaultTest: Tests to load (default: '.')
    * argv: Command line arguments (default: None; sys.argv is read)
    * testRunner: Test runner instance (default: None)
    * testLoader: Test loader instance (default: None)
    * env: Environment; ignored if config is provided (default: None;
      os.environ is read)
    * config: :class:`nose.config.Config` instance (default: None)
    * suite: Suite or list of tests to run (default: None). Passing a
      suite or lists of tests will bypass all test discovery and
      loading. *ALSO NOTE* that if you pass a unittest.TestSuite
      instance as the suite, context fixtures at the class, module and
      package level will not be used, and many plugin hooks will not
      be called. If you want normal nose behavior, either pass a list
      of tests, or a fully-configured :class:`nose.suite.ContextSuite`.
    * plugins: List of plugins to use; ignored if config is provided
      (default: load plugins with DefaultPluginManager)
    * addplugins: List of **extra** plugins to use. Pass a list of plugin
      instances in this argument to make custom plugins available while
      still using the DefaultPluginManager.

    With the exception that the ``exit`` argument is always set
    to False.
    R0(RBRR_(RgRh((s-/usr/lib/python2.7/site-packages/nose/core.pyR
s
t__main__cKstd||�dS(s�Collect and run tests in a single module only. Defaults to running
    tests in __main__. Additional arguments to TestProgram may be passed
    as keyword arguments.
    R2N(R(RnRh((s-/usr/lib/python2.7/site-packages/nose/core.pyR0scCs�d}td|�}tdt�d|�}|jd	d
g�t|�}|jrj|j|j�}n|jd
�}t||j�S(sTestSuite replacement entry point. Use anywhere you might use a
    unittest.TestSuite. The collector will, by default, load options from
    all config files and execute loader.loadTestsFromNames() on the
    configured testNames, or '.' if no testNames are configured.
    treportRRTR]RtexcludeRDRR3RR.(R�sprepareTestsprepareTestLoadersprepareTestRunnerssetOutputStream(R.(	RRRRIRRUR\RR"(tsetuptools_incompatRtconftloaderR:((s-/usr/lib/python2.7/site-packages/nose/core.pyR8s
		(ii(%R+t
__future__RtloggingR6R,RRtnose.configRRtnose.loaderRtnose.plugins.managerRRRtnose.resultRt
nose.suiteRt	nose.utilR	R
t	getLoggerRKR;t	compat_24t__all__RRRRR
RRR)(((s-/usr/lib/python2.7/site-packages/nose/core.pyt<module>s0	-�
	!