a
    ñ»joz  ã                   @   s`  d Z ddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZ ddl	mZ ddl	mZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ dZe e ¡Z!d a" a# a$ a% a&a'G dd„ de(ƒZ)dd„ Z*G dd„ dƒZ+G dd„ deƒZ,dd„ Z-G dd„ deƒZ.dd„ Z/dd„ Z0G dd„ deƒZ1dS ) a/  
Overview
========
The multiprocess plugin enables you to distribute your test run among a set of
worker processes that run tests in parallel. This can speed up CPU-bound test
runs (as long as the number of work processeses is around the number of
processors or cores available), but is mainly useful for IO-bound tests that
spend most of their time waiting for data to arrive from someplace else.
.. _multiprocessing : http://code.google.com/p/python-multiprocessing/

How tests are distributed
=========================
The ideal case would be to dispatch each test to a worker process separately.
This ideal is not attainable in all cases, however, because many test suites
depend on context (class, module, or package) fixtures.
The plugin can't know (unless you tell it -- see below!) if a context fixture
can be called many times concurrently (is re-entrant), or if it can be shared
among tests running in different processes. Therefore, if a context has
fixtures, the default behavior is to dispatch the suite to a worker as a unit.

Controlling distribution
========================
There are two context-level variables to control this default behavior:
* If a context's fixtures are re-entrant, set `_multiprocess_can_split_ = True`
in the context, and the plugin will dispatch tests in suites bound to that
context as if the context had no fixtures. This means that the fixtures will
execute concurrently and multiple times, typically once per test.
* If a context's fixtures can be shared by tests running in different processes
(such as a package-level fixture that starts an external http server or
initializes a shared database) then set ``_multiprocess_shared_ = True`` in
the context. These fixtures will then execute in the primary nose process,
and tests in those contexts will be individually dispatched to run in parallel.

How results are collected and reported
======================================
As each test or suite executes in a worker process, results (failures, errors,
and specially handled exceptions like SkipTest) are collected in that process.
When the worker process finishes, it returns results to the main nose process.
There, any progress output is printed (dots!), and the results from the
test run are combined into a consolidated result set.
When results have been received for all dispatched tests,
or all workers have died, the result summary is output as normal.

Beware!
=======
Not all test suites will benefit from, or even operate correctly using this
plugin. For example, CPU-bound tests will run more slowly if you don't have
multiple processors. There are also some differences in plugin interactions
and behaviors due to the way in which tests are dispatched and loaded.
In general, tests loaded under this plugin operate as if they were always in
directed mode instead of discovered mode. For instance, doctests in test
modules will always be found when using this plugin with the doctest plugin.
But the biggest issue you will face is probably concurrency. Unless you
have kept your tests as religiously pure unit tests, with no side-effects, no
ordering issues, and no external dependencies, chances are you will experience
odd, intermittent and unexplainable failures and errors when using this
plugin. This doesn't necessarily mean the plugin is broken;
it may mean that your test suite is not safe for concurrency.é    N)ÚTextTestRunner)Úfailure)Úloader)ÚPlugin)Úbytes_)ÚContextSuite)Útest_address)Ú_WritelnDecorator)ÚEmpty)Úwarn)ÚStringIOc                   @   s   e Zd Zddd„Zdd„ ZdS )ÚTimedOutExceptionú	Timed Outc                 C   s
   || _ d S ©N)Úvalue)Úselfr   © r   ú?E:\soccer\ml_env\Lib\site-packages\nose/plugins/multiprocess.pyÚ__init__V   s    zTimedOutException.__init__c                 C   s
   t | jƒS r   )Úreprr   ©r   r   r   r   Ú__str__Y   s    zTimedOutException.__str__N)r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   T   s   
r   c                  C   s|   zZddl m} ma t tjtj¡}| ƒ }t tj|¡ |j|j|j|j	|j
f\aaaa	a
W n tyv   tdtƒ Y n0 d S )Nr   )ÚManagerÚProcesszKmultiprocessing module is not available, multiprocess plugin cannot be used)Úmultiprocessingr   r   ÚsignalÚSIGINTÚSIG_IGNÚQueueÚPoolÚEventÚValueÚArrayÚImportErrorr   ÚRuntimeWarning)r   ÚoldÚmr   r   r   Ú
_import_mp]   s    ÿÿr*   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestLetc                 C   s:   z|  ¡ | _W n ty    Y n0 | ¡ | _t|ƒ| _d S r   )ÚidÚ_idÚAttributeErrorÚshortDescriptionÚ_short_descriptionÚstrÚ_str)r   Úcaser   r   r   r   m   s    
zTestLet.__init__c                 C   s   | j S r   )r-   r   r   r   r   r,   u   s    z
TestLet.idc                 C   s   | j S r   )r0   r   r   r   r   r/   x   s    zTestLet.shortDescriptionc                 C   s   | j S r   )r2   r   r   r   r   r   {   s    zTestLet.__str__N)r   r   r   r   r,   r/   r   r   r   r   r   r+   l   s   r+   c                   @   s8   e Zd ZdZdZi Zdd„ Zdd„ Zdd„ Zd	d
„ Z	dS )ÚMultiProcessz<Run tests in multiple processes. Requires processing module.iè  c                 C   s\   |j dd| dd¡dddd� |j d	d| d
d¡dddd� |j dd| dd¡ddd� dS )zRegister command-line options.z--processesÚstoreZNOSE_PROCESSESr   Úmultiprocess_workersZNUMaN  Spread test run among this many processes. Set a number equal to the number of processors or cores in your machine for best results. Pass a negative number to have the number of processes automatically set to the number of cores. Passing 0 means to disable parallel testing. Default is 0 unless NOSE_PROCESSES is set. [NOSE_PROCESSES])ÚactionÚdefaultÚdestÚmetavarÚhelpz--process-timeoutZNOSE_PROCESS_TIMEOUTé
   Úmultiprocess_timeoutZSECONDSzfSet timeout for return of results from each test runner process. Default is 10. [NOSE_PROCESS_TIMEOUT]z--process-restartworkerÚ
store_trueZNOSE_PROCESS_RESTARTWORKERFÚmultiprocess_restartworkerz™If set, will restart each worker process once their tests are done, this helps control memory leaks from killing the system. [NOSE_PROCESS_RESTARTWORKER])r7   r8   r9   r;   N)Ú
add_optionÚget)r   ÚparserÚenvr   r   r   Úoptions„   s$    
ü
ü
üzMultiProcess.optionsc              	   C   sæ   z| j  d¡ W n ty"   Y n0 t|dƒs8d| _dS |jrBdS || _zt|jƒ}W n t	t
fyp   d}Y n0 |râtƒ  tdu rŽd| _dS |dk r¦ddl}| ¡ }d| _|| j_t|jƒ}|| j_t|jƒ}|| j_d| j d< dS )zConfigure plugin.Zactiver6   FNr   T)ÚstatusÚpopÚKeyErrorÚhasattrÚenabledÚworkerÚconfigÚintr6   Ú	TypeErrorÚ
ValueErrorr*   r   r   Ú	cpu_countÚfloatr=   r?   )r   rD   rK   Úworkersr   ÚtÚrr   r   r   Ú	configureŸ   s:    



zMultiProcess.configurec                 C   s   |j | _dS )zYRemember loader class so MultiProcessTestRunner can instantiate
        the right loader.N)Ú	__class__ÚloaderClass)r   r   r   r   r   ÚprepareTestLoader¿   s    zMultiProcess.prepareTestLoaderc                 C   s   t |j| jj| j| jd�S )z0Replace test runner with MultiProcessTestRunner.)ÚstreamÚ	verbosityrK   rV   )ÚMultiProcessTestRunnerrX   rK   rY   rV   )r   Úrunnerr   r   r   ÚprepareTestRunnerÄ   s    
þzMultiProcess.prepareTestRunnerN)
r   r   r   Ú__doc__ZscorerE   rD   rT   rW   r\   r   r   r   r   r4      s    r4   c                 C   s
   t ƒ ‚d S r   )r   )ÚsigÚframer   r   r   ÚsignalhandlerË   s    r`   c                       s€   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	eƒZdd„ Z
e	e
ƒZ
dd„ Zdd„ Ze	eƒZdd„ Zdd„ Z‡  ZS )rZ   g      @c                    s*   |  dtj¡| _tt| ƒjf i |¤Ž d S )NrV   )rF   r   ZdefaultTestLoaderrV   ÚsuperrZ   r   )r   Úkw©rU   r   r   r   Ó   s    zMultiProcessTestRunner.__init__c           
   
   C   s~  |   |¡D �]l}t d|t|ƒ¡ t|tjjƒrRt|jt	j
ƒrRt d¡ ||ƒ q
t|tƒr~|jt	j
u r~t d¡ ||ƒ q
q
t|tƒ�rV|  |¡�rVt d|¡ z| ¡  W nH ttfyÆ   ‚ Y nŽ työ   t dt ¡ ¡ | |t ¡ ¡ Y n^0 | |¡ |j�rB|jj |g ¡}|d d… D ]}t|ddƒ�r&d|_�q&|  |||||¡ q
|  |||¡}	t d	t|ƒ|	|¡ q
d S )
NzNext batch %s (%s)zCase is a Failurez%s has shared fixturesz%s setup failedé   Ú_multiprocess_shared_FTzQueued test %s (%s) to %s)Ú	nextBatchÚlogÚdebugÚtypeÚ
isinstanceÚnoser3   ÚTestÚtestr   ÚFailurer   ÚcontextÚsharedFixturesÚsetUpÚKeyboardInterruptÚ
SystemExitÚ	ExceptionÚsysÚexc_infoÚaddErrorÚappendÚfactoryrA   ÚgetattrÚ_multiprocess_can_split_ÚcollectÚaddtaskÚlen)
r   rm   Ú	testQueueÚtasksÚto_teardownÚresultr3   Z	ancestorsZanÚ	test_addrr   r   r   r|   ×   sL    ÿþ
ÿ
þ



þzMultiProcessTestRunner.collectc                 C   sˆ   t dtdƒƒ}t dt ¡ ƒ}tƒ }tt|||||||| j|jt 	| j
¡f
d�}	||	_||	_||	_t tjt¡}
|	 ¡  t tj|
¡ |	S )NÚcÚ Úd)ÚtargetÚargs)r$   r   Útimer#   r   r[   rV   rU   ÚpickleÚdumpsrK   ÚcurrentaddrÚcurrentstartÚkeyboardCaughtr   ÚSIGILLr`   Ústart)r   Úiworkerr   ÚresultQueueÚ
shouldStopr‚   rŒ   r�   rŽ   Úpr(   r   r   r   ÚstartProcessÿ   s0    
öþz#MultiProcessTestRunner.startProcessc                  C   s   t  d| |t ¡ ¡ | jj |¡}|dur.|}| jj | j¡}|durL|| _t	ƒ }t	ƒ }g }g }g }g }	t
ƒ }
|  ¡ }t ¡ }|  ||||	|¡ t  d| jj¡ t| jjƒD ]0}|  ||||
|¡}| |¡ t  d|d ¡ q¬t|ƒ}| jj}d}�z||�rXt  dt|ƒ||¡ �zL|j|d�\}}}}t  d||t|ƒ¡ zLz| |¡ W n" t�yn   t  d	||¡ Y n0 |t|ƒ7 }| |¡ W n8 t�yÀ   t  d
|¡ t  dtt|ƒd ƒ¡ Y n0 | ||g¡ |  ||¡ | jj�rþ| ¡ �sþ|
 ¡  W �qX| jj �rZt  d|¡ || j!dd� |
 "¡ �sZ| #¡ �sZt  d|¡ |  ||||
|¡||< W �n– t$�yô   d}t  |t|ƒ| #¡ t|ƒ¡ d}t%|ƒD �]2\}}| &¡ �ršt'|j(j)dƒ}t ¡ |j*j) }t|ƒdk�rú|| jjd k�rút  d|¡ nd}t|ƒdk�rš|| jjd k�ršd}t  |||¡ t'dƒ|j(_)|j+ ,¡  t ¡ }|j+ "¡ �sš| &¡ �ršt ¡ | | j-k�r®d}t  .||¡ | /¡  |  ||||
|¡ ||< }�qšt 0|j1t2j3¡ t 4d¡ �qN�qš|�sð| #¡ �rðt  d¡ Y �qXY n0 | jj}|D ]R}| &¡ �rt|j(j)ƒdk�rt ¡ |j*j) }|| jjk�rt5|| jj| ƒ}�qqöt  dt|ƒt|ƒ¡ W nH t6t7f�y¸ } z*t  8d¡ |}| 9|t: ;¡ ¡ W Y d}~n
d}~0 0 �z|	D ]\}t  d|¡ z| <¡  W n< t6t7f�yø   ‚ Y n$ t=�y   | 9|t: ;¡ ¡ Y n0 �qÂt ¡ }| >¡  | ?||¡ | jj @|¡ |du �r‚t  d¡ |D ]}| &¡ �rb|jAddd� �qbt%|ƒD ]>\}}| &¡ �rŠt  d|¡ | !¡  | &¡ �rŠt  d|¡ �qŠW nN t6t7f�y   t  8d ¡ |D ]}| &¡ �rî| /¡  �qî|�r|‚n‚ Y n0 |S )!a   Execute the test (which may be a suite). If the test is a suite,
        distribute it out among as many processes as have been configured, at
        as fine a level as is possible given the context fixtures defined in
        the suite or any sub-suites.z%s.run(%s) (%s)NzStarting %s workerszStarted worker process %sé   z5Waiting for results (%s/%s tasks), next timeout=%.3fs©Útimeoutz1Results received for worker %d, %s, new tasks: %dz)worker %s failed to remove from tasks: %szGot result for unknown task? %szcurrent: %sr   zjoining worker %sz!starting new process on worker %sz3Timeout - %s tasks pending (empty testQueue=%r): %sFÚasciigš™™™™™¹?zHWorker %d finished its work item, but is not exiting. Do we wait for it?TzTimed out worker %s: %sr…   zterminating worker %szAll workers are deadzCompleted %s tasks (%s remain)z4parent received ctrl-c when waiting for test resultsz#Tearing down shared fixtures for %szTell all workers to stopÚSTOP©Úblockzfailed to join worker %sz=parent received ctrl-c when shutting down: stop all processes)Brg   rh   ÚosÚgetpidrK   ÚpluginsZprepareTestZsetOutputStreamrX   r!   r#   Z_makeResultr‰   r|   r6   Úranger•   rx   r~   r=   rA   ÚremoverN   ÚwarningÚextendrG   r1   ÚlistÚconsolidateZstopOnErrorZwasSuccessfulÚsetr?   ÚjoinÚis_setÚemptyr
   Ú	enumerateÚis_aliver   rŒ   r   r�   rŽ   ÚclearÚwaitkilltimeÚerrorÚ	terminateÚkillÚpidr   r�   ÚsleepÚminrr   rs   Úinforw   ru   rv   ÚtearDownrt   ZprintErrorsZprintSummaryÚfinalizeÚput) r   rm   ÚwrapperÚwrappedr   r’   r€   Ú	completedrQ   r�   r“   r‚   r�   Úir”   Ztotal_tasksZnexttimeoutZthrownErrorr‘   ÚaddrZnewtask_addrsÚbatch_resultÚmsgZ	any_aliveÚwZworker_addrZtimeprocessingZstartkilltimeÚer3   ÚstoprJ   r   r   r   Úrun  sn   
ÿ

þ
ÿ

þþ
ÿÿ
ÿû

ÿ
ÿþþ
ÿ
ÿþ
ÿþ
ÿÿûÿ
	
ÿþ
ÿ
&




ÿ
zMultiProcessTestRunner.runc                 C   st   d }t |tjjƒr.t|jdƒr.d |j_|jj}t 	|¡}| j
||fdd� |d ur^|t|ƒ7 }|d urp| |¡ |S )NÚargFr›   )rj   rk   r3   rl   rH   rm   Z
descriptorrÃ   rZ   Úaddressr·   r1   rx   )r   r€   r3   rÃ   rƒ   r   r   r   r}   Ú  s    

zMultiProcessTestRunner.addtaskc                 C   sº   t | dƒr|  ¡ \}}}n(t | dƒr6t| jƒ\}}}ntd|  ƒ‚g }|d u rp|d u rdtd|  ƒ‚q˜| |¡ n(tj |¡\}}| 	d¡rŽ|}| |¡ |d urª| |¡ d 
tt|ƒ¡S )NrÄ   ro   zUnable to convert %s to addresszUnaddressable case %sr   ú:)rH   rÄ   r   ro   rt   rx   r�   ÚpathÚsplitÚ
startswithr§   Úmapr1   )r3   ÚfileÚmodÚcallÚpartsÚdirnameÚbasenamer   r   r   rÄ   è  s"    




zMultiProcessTestRunner.addressc                 c   s¬   t |dƒrt|jddƒsd S t|tƒr2| | j¡sJt|ddƒrJt|tjƒsŽt|tƒr†t	|ƒ}t
|ƒdkr†t|d dd ƒ|jkr†|d }|V  n|D ]}|  |¡E d H  q’d S )Nro   Z_multiprocess_TZ	can_splitr–   r   )rH   rz   ro   rj   r   ZhasFixturesÚcheckCanSplitÚunittestZ	TestSuiter¤   r~   rf   )r   rm   Z	containedr3   r   r   r   rf   ÿ  s*    
þ
ý
û
ú

ÿþz MultiProcessTestRunner.nextBatchc                 C   s   |sdS t | ddƒrdS dS )zÉCallback to check whether the fixtures found in a context or
        ancestor are ones we care about. Contexts can tell us that their
        fixtures are reentrant by setting _multiprocess_can_split_.Fr{   T©rz   )ro   Zfixtr   r   r   rÐ     s
    z$MultiProcessTestRunner.checkCanSplitc                 C   s    t |dd ƒ}|sdS t |ddƒS )Nro   Fre   rÒ   )r   r3   ro   r   r   r   rp   #  s    z%MultiProcessTestRunner.sharedFixturesc                 C   sè   t  d|¡ z|\}}}}}W n2 tyP   t  d|¡ tjt ¡ Ž |ƒ Y d S 0 | j |¡ | j	|7  _	|j
 |¡ |j |¡ t| ¡ ƒD ]B\}\}	}
}||jvr¸g |
|f|j|< |j| \}}}| |	¡ q�t  d||j	¡ d S )Nzbatch result is %szresult in unexpected format %szRan %s tests (total: %s))rg   rh   rN   r   rn   ru   rv   rX   ÚwriteÚtestsRunÚfailuresr£   Úerrorsr¤   ÚitemsÚerrorClasses)r   r‚   r½   ÚoutputrÔ   rÕ   rÖ   rØ   ÚkeyÚstorageÚlabelÚisfailZ	mystorageZ_junkr   r   r   r¥   )  s"    
z"MultiProcessTestRunner.consolidate)r   r   r   r­   r   r|   r•   rÂ   r}   ÚstaticmethodrÄ   rf   rÐ   rp   r¥   Ú__classcell__r   r   rc   r   rZ   Ï   s   ( ?	rZ   c
           
      C   sf   zBzt | |||||||||	ƒ
W W S  ty>   t d| ¡ Y n0 W n ty`   t d| ¡ Y n0 d S )Nz&Worker %s keyboard interrupt, stoppingz%Worker %s timed out waiting for tasks)Ú__runnerrr   rg   rh   r
   )
Úixr   r’   rŒ   r�   rŽ   r“   rV   ÚresultClassrK   r   r   r   r[   =  s    

þr[   c
                    sØ  t  ˆ ¡‰ ˆ  ¡ }
td urBtD ]"}|ƒ }| |
i ¡ ˆ j |¡ qˆ j ˆ jˆ ¡ ˆ j 	¡  t
 d| t ¡ ¡ |ˆ d�}t|j_‡ ‡fdd„}‡ ‡fdd„}dd„ }t|d	ƒD �]\}}| ¡ rÒt
 d
| ¡  �qÈ|ƒ }| |g¡}ˆ|_g |_||_t
 d| ||¡ zZ|d u�r|t|ƒ }t|ƒ|_t ¡ |_||ƒ tdƒ|_| | ||j||ƒf¡ W �nX t�y< } zÂt|tƒ}|�rŠ| ¡  t |jƒ�rê|�r¢d}nd}t
 || |¡ tdƒ|_t!j"t# $¡ Ž |ƒ | | ||j||ƒf¡ n6|�röd}nd}t
 || |¡ | | ||j||ƒf¡ |�s(‚ W Y d }~n†d }~0  t%�yf   tdƒ|_t
 d| ¡ ‚ Y nT t&�y¸   tdƒ|_t
 d| ¡ t!j"t# $¡ Ž |ƒ | | ||j||ƒf¡ Y n0 ˆ j'r® �qÈq®t
 d| ¡ d S )NzWorker %s executing, pid=%d)rK   c                      s   ˆj ˆ jd�S )Nr—   )rA   r=   r   )rK   r   r   r   rA   ^  s    z__runner.<locals>.getc                     s4   t tƒ ƒ} ˆ| dˆ jˆ d�}ˆ j |¡}|r0|S |S )Nr–   )ZdescriptionsrY   rK   )r	   r   rY   rŸ   ZprepareTestResult)rX   r‚   Zplug_result)rK   râ   r   r   Ú
makeResulta  s    

ÿz__runner.<locals>.makeResultc                 S   sp   dd„ | j D ƒ}dd„ | jD ƒ}i }t| j ¡ ƒD ]&\}\}}}dd„ |D ƒ||f||< q2| j ¡ | j|||fS )Nc                 S   s   g | ]\}}t |ƒ|f‘qS r   ©r+   ©Ú.0r„   Úerrr   r   r   Ú
<listcomp>l  ó    z+__runner.<locals>.batch.<locals>.<listcomp>c                 S   s   g | ]\}}t |ƒ|f‘qS r   rä   rå   r   r   r   rè   m  ré   c                 S   s   g | ]\}}t |ƒ|f‘qS r   rä   rå   r   r   r   rè   q  ré   )rÕ   rÖ   r¤   rØ   r×   rX   ÚgetvaluerÔ   )r‚   rÕ   rÖ   rØ   rÚ   rÛ   rÜ   rÝ   r   r   r   Úbatchk  s    ÿ
ûz__runner.<locals>.batchrš   zWorker %d STOPPEDzWorker %s Test is %s (%s)r…   z,Worker %s timed out, failing current test %sz5Worker %s keyboard interrupt, failing current test %szWorker %s test %s timed outz$Worker %s test %s keyboard interruptzWorker %s system exitz1Worker %s error running test or returning resultszWorker %s ending)(rŠ   ÚloadsZparserClassÚ_instantiate_pluginsZ
addOptionsrŸ   Z	addPluginrT   rD   Úbeginrg   rh   r�   rž   ÚNoSharedFixtureContextSuiteZ
suiteClassÚiterr¨   Ú	exceptionZloadTestsFromNamesr   r€   rÃ   r1   r   r   r‰   r·   rr   rj   r   r¦   r~   r   rn   ru   rv   rs   rt   r?   )rá   r   r’   rŒ   r�   rŽ   r“   rV   râ   rK   Zdummy_parserZpluginclassÚpluginr   rA   rã   rë   rƒ   rÃ   r‚   rm   rÀ   r˜   r¾   r   )rK   râ   r   r   rà   M  s†    








ÿ


ÿrà   c                       s@   e Zd ZdZdZdZdZ‡ fdd„Z‡ fdd„Zdd„ Z	‡  Z
S )	rï   zîContext suite that never fires shared fixtures.
    When a context sets _multiprocess_shared_, fixtures in that context
    are executed by the main process. Using this class prevents them
    from executing in the runner process as well.Nc                    s$   t |ddƒrd S tt| ƒ |¡ d S ©Nre   F)rz   ra   rï   ÚsetupContext©r   ro   rc   r   r   rô   ½  s    z(NoSharedFixtureContextSuite.setupContextc                    s$   t |ddƒrd S tt| ƒ |¡ d S ró   )rz   ra   rï   ÚteardownContextrõ   rc   r   r   rö   Â  s    z+NoSharedFixtureContextSuite.teardownContextc                 C   s.  t  dt| ƒ| | j¡ | jr0|  || ¡| }}n
|| }}z|  ¡  W n< tyZ   ‚ Y n* ty‚   d| _| 	| |  
¡ ¡ Y dS 0 �zN| jD ]ð}t|tjjƒr¶| jdur¶| j|j_n| j|_| j|_| j|_|jrät  d¡  �q€z||ƒ W qŽ t�y| } zrt|tƒ}|�rd}nd}t  ||| ¡ ttt|ƒƒt ¡ d f}|jj 	||¡ | 	||¡ |�sh‚ W Y d}~qŽd}~0 0 qŽW d| _z|  ¡  W n> t�yª   ‚ Y n* t�yÒ   d	| _| 	| |  
¡ ¡ Y n0 nTd| _z|  ¡  W n> t�yþ   ‚ Y n* t�y&   d	| _| 	| |  
¡ ¡ Y n0 0 dS )
z,Run tests in suite inside of suite fixtures.z#suite %s (%s) run called, tests: %sÚsetupNZstoppingz(Timeout when running test %s in suite %sz2KeyboardInterrupt when running test %s in suite %srd   TZteardown)rg   rh   r,   Z_testsZresultProxyrq   rr   rt   Zerror_contextrw   Z	_exc_inforj   rk   r3   rl   rÃ   rm   r   r€   r“   r   r1   ru   rv   rK   rŸ   Zhas_runrµ   )r   r‚   Úorigrm   rÀ   r˜   r¾   rç   r   r   r   rÂ   Ç  sr    ÿ



ÿ

ýøzNoSharedFixtureContextSuite.run)r   r   r   r]   r   r€   rÃ   rô   rö   rÂ   rß   r   r   rc   r   rï   ´  s   rï   )2r]   Úloggingr�   ru   r‰   rÑ   rŠ   r   Z	nose.caserk   Z	nose.corer   r   r   Znose.plugins.baser   Znose.pyversionr   Z
nose.suiter   Z	nose.utilr   Zunittest.runnerr	   Úqueuer
   Úwarningsr   Úior   rí   Ú	getLoggerr   rg   r   r!   r"   r#   r$   r%   rr   r   r*   r+   r4   r`   rZ   r[   rà   rï   r   r   r   r   Ú<module>   sB   :
	L  pg