o
    ÔÁgÖ‰  ã                   @   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	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 zddlmZ W n eym   ddlmZ Y nw ddlmZ ddlmZ zddl m!Z! W n ey   ddl Z Y nw 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ƒZ0dd„ Z1G dd„ deƒZ2dd„ Z3dd„ Z4G dd „ d eƒZ5d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.

.. note ::

   See :doc:`../doc_tests/test_multiprocess/multiprocess` for
   additional documentation and examples. Use of this plugin on python
   2.5 or earlier requires the multiprocessing_ module, also available
   from PyPI.

.. _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 entire suite to a worker as
a unit.

Controlling distribution
^^^^^^^^^^^^^^^^^^^^^^^^

There are two context-level variables that you can use 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, test loading under this plugin operates as if it 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.

New Features in 1.1.0
=====================

* functions generated by test generators are now added to the worker queue
  making them multi-threaded.
* fixed timeout functionality, now functions will be terminated with a
  TimedOutException exception when they exceed their execution time. The
  worker processes are not terminated.
* added ``--process-restartworker`` option to restart workers once they are
  done, this helps control memory usage. Sometimes memory leaks can accumulate
  making long runs very difficult.
* added global _instantiate_plugins to configure which plugins are started
  on the worker processes.

é    N)ÚTextTestRunner)Úfailure)Úloader)ÚPlugin)Úbytes_)ÚTextTestResult)Ú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   úW/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/nose/plugins/multiprocess.pyÚ__init__‡   ó   
zTimedOutException.__init__c                 C   s
   t | jƒS r   )Úreprr   ©r   r   r   r   Ú__str__‰   r   zTimedOutException.__str__N)r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   †   s    
r   c                  C   s|   z.d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 d S  ty=   tdtƒ Y d S w )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w | ¡ | _t|ƒ| _d S r   )ÚidÚ_idÚAttributeErrorÚshortDescriptionÚ_short_descriptionÚstrÚ_str)r   Úcaser   r   r   r   £   s   ÿ
zTestLet.__init__c                 C   ó   | j S r   )r/   r   r   r   r   r.   «   ó   z
TestLet.idc                 C   r6   r   )r2   r   r   r   r   r1   ®   r7   zTestLet.shortDescriptionc                 C   r6   r   )r4   r   r   r   r   r   ±   r7   zTestLet.__str__N)r   r   r   r   r.   r1   r   r   r   r   r   r-   ¢   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 )ÚMultiProcesszF
    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 )z0
        Register command-line options.
        z--processesÚstoreÚNOSE_PROCESSESr   Úmultiprocess_workersÚ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-timeoutÚNOSE_PROCESS_TIMEOUTé
   Úmultiprocess_timeoutÚSECONDSzfSet timeout for return of results from each test runner process. Default is 10. [NOSE_PROCESS_TIMEOUT]z--process-restartworkerÚ
store_trueÚ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])r=   r>   r?   rA   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w t|dƒsd| _dS |jr!dS || _zt|jƒ}W n t	t
fy8   d}Y nw |rƒtƒ  tdu rGd| _dS |dk rcz
ddl}| ¡ }W n tyb   d| _Y dS w d| _|| j_t|jƒ}|| j_t|jƒ}|| j_d| j d< dS dS )z#
        Configure plugin.
        Úactiver;   FNr   T)ÚstatusÚpopÚKeyErrorÚhasattrÚenabledÚworkerÚconfigÚintr;   Ú	TypeErrorÚ
ValueErrorr,   r   r   Ú	cpu_countÚNotImplementedErrorÚfloatrD   rH   )r   rM   rU   Úworkersr   ÚtÚrr   r   r   Ú	configureÛ   sJ   ÿ
ÿþ

ìzMultiProcess.configurec                 C   s   |j | _dS )zbRemember 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 )z9Replace test runner with MultiProcessTestRunner.
        )ÚstreamÚ	verbosityrU   ra   )ÚMultiProcessTestRunnerrc   rU   rd   ra   )r   Úrunnerr   r   r   ÚprepareTestRunner
  s
   ýzMultiProcess.prepareTestRunnerN)
r   r   r   Ú__doc__ÚscorerO   rM   r_   rb   rg   r   r   r   r   r8   ´   s     )r8   c                 C   s   t ƒ ‚r   )r   )ÚsigÚframer   r   r   Úsignalhandler  r7   rl   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 )re   g      @c                    s*   |  dtj¡| _tt| ƒjdi |¤Ž d S )Nra   r   )rP   r   ÚdefaultTestLoaderra   Úsuperre   r   )r   Úkw©r`   r   r   r     s   zMultiProcessTestRunner.__init__c           
   
   C   sd  |   |¡D ]ª}t d|t|ƒ¡ t|tjjƒr(t|jt	j
ƒr(t d¡ ||ƒ qt|tƒr=|jt	j
u r=t d¡ ||ƒ qt|tƒrž|  |¡ržt d|¡ z| ¡  W n ttfy]   ‚    t dt ¡ ¡ | |t ¡ ¡ Y q| |¡ |jr”|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Únoser5   ÚTestÚtestr   ÚFailurer   ÚcontextÚsharedFixturesÚsetUpÚKeyboardInterruptÚ
SystemExitÚsysÚexc_infoÚaddErrorÚappendÚfactoryrJ   ÚgetattrÚ_multiprocess_can_split_ÚcollectÚaddtaskÚlen)
r   rz   Ú	testQueueÚtasksÚto_teardownÚresultr5   Ú	ancestorsÚanÚ	test_addrr   r   r   rˆ     sD   ÿ


€
ÿÞ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   rf   ra   r`   ÚpickleÚdumpsrU   ÚcurrentaddrÚcurrentstartÚkeyboardCaughtr    ÚSIGILLrl   Ústart)r   Úiworkerr‹   ÚresultQueueÚ
shouldStoprŽ   rš   r›   rœ   Úpr*   r   r   r   ÚstartProcessE  s,   
øÿ
z#MultiProcessTestRunner.startProcessc                 C   sþ  t  d| |t ¡ ¡ | jj |¡}|dur|}| jj | j¡}|dur&|| _t	ƒ }t	ƒ }g }g }g }g }	t
ƒ }
|  ¡ }t ¡ }|  ||||	|¡ t  d| jj¡ t| jjƒD ]}|  ||||
|¡}| |¡ t  d|d ¡ qVt|ƒ}| jj}d}z¹|r't  dt|ƒ||¡ z¡|j|d\}}}}t  d||t|ƒ¡ z%z| |¡ W n tyµ   t  d	||¡ Y nw |t|ƒ7 }| |¡ W n tyÝ   t  d
|¡ t  dtt|ƒd ƒ¡ Y nw | ||g¡ |  ||¡ | jjrú| ¡ sú|
 ¡  W n-| jj r(t  d|¡ || j!dd |
 "¡ s(| #¡ s(t  d|¡ |  ||||
|¡||< W nË t$yô   t  dt|ƒ| #¡ t|ƒ¡ d}t%|ƒD ]\}}| &¡ rát'|j(j)dƒ}t ¡ |j*j) }t|ƒdkrt|| jjd krtt  d|¡ nd}t|ƒdkrá|| jjd krát  d||¡ t'dƒ|j(_)|j+ ,¡  t ¡ }|j+ "¡ sá| &¡ rát ¡ | | j-krÉt  .d|¡ | /¡  |  ||||
|¡ ||< }nt 0|j1t2j3¡ t 4d¡ |j+ "¡ sá| &¡ s§qE|sò| #¡ ròt  d¡ Y n5Y nw | jj}|D ])}| &¡ r#t|j(j)ƒdkr#t ¡ |j*j) }|| jjkr#t5|| jj| ƒ}qû|s~t  dt|ƒt|ƒ¡ W n$ t6t7fyW } zt  8d¡ |}| 9|t: ;¡ ¡ W Y d}~nd}~ww z‚|	D ]'}t  d|¡ z| <¡  W q[ t6t7fyu   ‚    | 9|t: ;¡ ¡ Y q[t ¡ }| =¡  | >||¡ | jj ?|¡ |du r´t  d¡ |D ]}| &¡ r²|j@ddd q¤t%|ƒD ]\}}| &¡ rÖt  d|¡ | !¡  | &¡ rÖt  d|¡ q¸W |S  t6t7fyþ   t  8d ¡ |D ]}| &¡ rö| /¡  që|rý|‚‚ w )!a  
        Execute the test (which may be a test 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 %sz8Timed out with %s tasks pending (empty testQueue=%r): %sFÚasciigš™™™™™¹?zLworker %d has 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 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)Art   ru   ÚosÚgetpidrU   ÚpluginsÚprepareTestÚsetOutputStreamrc   r#   r%   Ú_makeResultr—   rˆ   r;   Úranger£   r„   rŠ   rD   rJ   ÚremoverX   r   ÚextendrQ   r3   ÚlistÚconsolidateÚstopOnErrorÚwasSuccessfulÚsetrH   ÚjoinÚis_setÚemptyr   Ú	enumerateÚis_aliver   rš   r   r›   rœ   ÚclearÚwaitkilltimeÚerrorÚ	terminateÚkillÚpidr    r   ÚsleepÚminr   r€   Úinforƒ   r   r‚   ÚtearDownÚprintErrorsÚprintSummaryÚfinalizeÚput)r   rz   ÚwrapperÚwrappedr‹   r    rŒ   Ú	completedr\   r   r¡   rŽ   rž   Úir¢   Útotal_tasksÚnexttimeoutÚthrownErrorrŸ   ÚaddrÚnewtask_addrsÚbatch_resultÚ	any_aliveÚwÚworker_addrÚtimeprocessingÚstartkilltimeÚer5   ÚstoprT   r   r   r   Úrun[  s:  

ÿÿ
ÿÿÿþÿ
€þ
þÿ

ô€
€Õ,
ÿ€ªX
€û


€

€û÷

€
ù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r8| |¡ |S )NÚargFr©   )rw   rx   r5   ry   rR   rz   Ú
descriptorrÞ   re   ÚaddressrË   r3   r„   )r‹   rŒ   r5   rÞ   r‘   r   r   r   r‰     s   

zMultiProcessTestRunner.addtaskc                 C   s¸   t | dƒr|  ¡ \}}}nt | dƒrt| jƒ\}}}ntd|  ƒ‚g }|d u r7|d u r1td|  ƒ‚| |¡ ntj |¡\}}| 	d¡rF|}| |¡ |d urT| |¡ d 
tt|ƒ¡S )Nrà   r|   zUnable to convert %s to addresszUnaddressable case %sr   ú:)rR   rà   r	   r|   Ú	Exceptionr„   r«   ÚpathÚsplitÚ
startswithr¹   Úmapr3   )r5   Ú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ƒr| | j¡s&t|ddƒr&t|tjƒsIt|tƒrDt	|ƒ}t
|ƒdkrDt|d dd ƒ|jkrD|d }|V  d S |D ]}|  |¡D ]}|V  qRqKd S )Nr|   Ú_multiprocess_TÚ	can_splitr¤   r   )rR   r†   r|   rw   r   ÚhasFixturesÚcheckCanSplitÚunittestÚ	TestSuiter´   rŠ   rs   )r   rz   Ú	containedr5   Úbatchr   r   r   rs   :  s4   €


ÿ
þ
ý

ÿÿ
ÿÿz MultiProcessTestRunner.nextBatchc                 C   s   |sdS t | ddƒrdS dS )a8  
        Callback that we use 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_. So if we see that, we return False to
        disregard those fixtures.
        Fr‡   T©r†   )r|   Úfixtr   r   r   rð   Z  s
   	z$MultiProcessTestRunner.checkCanSplitc                 C   s    t |dd ƒ}|s
dS t |ddƒS )Nr|   Frr   rõ   )r   r5   r|   r   r   r   r}   j  s   z%MultiProcessTestRunner.sharedFixturesc                 C   sè   t  d|¡ z	|\}}}}}W n ty(   t  d|¡ tjt ¡ Ž |ƒ Y d S w | j |¡ | j	|7  _	|j
 |¡ |j |¡ t| ¡ ƒD ]!\}\}	}
}||jvr\g |
|f|j|< |j| \}}}| |	¡ qHt  d||j	¡ d S )Nzbatch result is %szresult in unexpected format %szRan %s tests (total: %s))rt   ru   rX   r   r{   r   r‚   rc   ÚwriteÚtestsRunÚfailuresr³   Úerrorsr´   ÚitemsÚerrorClasses)r   rŽ   rÕ   Úoutputrø   rù   rú   rü   ÚkeyÚstorageÚlabelÚisfailÚ	mystorageÚ_junkr   r   r   rµ   p  s$   ý
z"MultiProcessTestRunner.consolidate)r   r   r   r¿   r   rˆ   r£   rÝ   r‰   Ústaticmethodrà   rs   rð   r}   rµ   Ú__classcell__r   r   rp   r   re     s     ( 7 re   c
           
      C   sd   z!zt | |||||||||	ƒ
W W S  ty!   t d| ¡ Y W d S w  ty1   t d| ¡ Y d S w )Nz&Worker %s keyboard interrupt, stoppingz%Worker %s timed out waiting for tasks)Ú__runnerr   rt   ru   r   )
Úixr‹   r    rš   r›   rœ   r¡   ra   ÚresultClassrU   r   r   r   rf   ‡  s   
ÿÿÿrf   c
                    s¸  t  ˆ ¡‰ ˆ  ¡ }
td ur!tD ]}|ƒ }| |
i ¡ ˆ j |¡ qˆ j ˆ jˆ ¡ ˆ j 	¡  t
 d| t ¡ ¡ |ˆ d}t|j_‡ ‡fdd„}‡ ‡fdd„}dd„ }t|d	ƒD ]ü\}}| ¡ rgt
 d
| ¡  ní|ƒ }| |g¡}ˆ|_g |_||_t
 d| ||¡ z+|d urŒ|t|ƒ }t|ƒ|_t ¡ |_||ƒ tdƒ|_| | ||j||ƒf¡ W n  ty } z]t|tƒ}|rÀ| ¡  t |jƒrî|rÊd}nd}t
 || |¡ tdƒ|_t!j"t# $¡ Ž |ƒ | | ||j||ƒf¡ n|ród}nd}t
 || |¡ | | ||j||ƒf¡ |s‚ W Y d }~n;d }~w t%y)   tdƒ|_t
 d| ¡ ‚    tdƒ|_t
 d| ¡ t!j"t# $¡ Ž |ƒ | | ||j||ƒf¡ Y ˆ j&rS nqWt
 d| ¡ d S )NzWorker %s executing, pid=%d)rU   c                      s   ˆj ˆ jdS )Nr¥   )rJ   rD   r   )rU   r‹   r   r   rJ   ¢  s   z__runner.<locals>.getc                     s4   t tƒ ƒ} ˆ| dˆ jˆ d}ˆ j |¡}|r|S |S )Nr¤   )Údescriptionsrd   rU   )r
   r   rd   r­   ÚprepareTestResult)rc   rŽ   Úplug_result)rU   r  r   r   Ú
makeResult¥  s   
þz__runner.<locals>.makeResultc                 S   sp   dd„ | j D ƒ}dd„ | jD ƒ}i }t| j ¡ ƒD ]\}\}}}dd„ |D ƒ||f||< q| j ¡ | j|||fS )Nc                 S   ó   g | ]
\}}t |ƒ|f‘qS r   ©r-   ©Ú.0r’   Úerrr   r   r   Ú
<listcomp>°  ó    z+__runner.<locals>.batch.<locals>.<listcomp>c                 S   r  r   r  r  r   r   r   r  ±  r  c                 S   r  r   r  r  r   r   r   r  ´  r  )rù   rú   r´   rü   rû   rc   Úgetvaluerø   )rŽ   rù   rú   rü   rþ   rÿ   r   r  r   r   r   rô   ¯  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˜   ÚloadsÚparserClassÚ_instantiate_pluginsÚ
addOptionsr­   Ú	addPluginr_   rM   Úbeginrt   ru   r«   r¬   ÚNoSharedFixtureContextSuiteÚ
suiteClassÚiterrº   Ú	exceptionÚloadTestsFromNamesr‹   rŒ   rÞ   r3   r   r   r—   rË   r   rw   r   r¸   rŠ   r   r{   r   r‚   r€   rH   )r  r‹   r    rš   r›   rœ   r¡   ra   r  rU   Údummy_parserÚpluginclassÚpluginr   rJ   r  rô   r‘   rÞ   rŽ   rz   rÛ   r¦   Úmsgr   )rU   r  r‹   r   r  ’  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  a   
    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 suite class prevents them
    from executing in the runner process as well.

    Nc                    ó$   t |ddƒrd S tt| ƒ |¡ d S ©Nrr   F)r†   rn   r  ÚsetupContext©r   r|   rp   r   r   r&  ÿ  ó   z(NoSharedFixtureContextSuite.setupContextc                    r$  r%  )r†   rn   r  ÚteardownContextr'  rp   r   r   r)    r(  z+NoSharedFixtureContextSuite.teardownContextc                 C   sò  t  dt| ƒ| | j¡ | jr|  || ¡|}}n||}}z|  ¡  W n ty+   ‚    d| _| | |  	¡ ¡ Y dS z›| jD ]s}t
|tjjƒrT| jdurT| j|j_n| j|_| j|_| j|_|jrjt  d¡  nJz||ƒ W q@ ty³ } z7t
|tƒ}|r‚d}nd}t  ||| ¡ ttt|ƒƒt ¡ d f}|jj ||¡ | ||¡ |s©‚ W Y d}~q@d}~ww W d| _z|  ¡  W dS  tyÇ   ‚    d	| _| | |  	¡ ¡ Y dS d| _z|  ¡  W w  tyé   ‚    d	| _| | |  	¡ ¡ Y w )
z5Run tests in suite inside of suite fixtures.
        z#suite %s (%s) run called, tests: %sÚsetupNÚstoppingz(Timeout when running test %s in suite %sz2KeyboardInterrupt when running test %s in suite %srq   TÚteardown)rt   ru   r.   Ú_testsÚresultProxyr~   r   Úerror_contextrƒ   Ú	_exc_inforw   rx   r5   ry   rÞ   rz   r‹   rŒ   r¡   r   r3   r   r‚   rU   r­   Úhas_runrÇ   )r   rŽ   Úorigrz   rÛ   r¦   r#  r  r   r   r   rÝ     sx   ÿ





ÿÿ€õ€øzNoSharedFixtureContextSuite.run)r   r   r   rh   r‹   rŒ   rÞ   r&  r)  rÝ   r  r   r   rp   r   r  ó  s    r  )6rh   Úloggingr«   r   r—   Ú	tracebackrñ   r˜   r    Ú	nose.caserx   Ú	nose.corer   r   r   Únose.plugins.baser   Únose.pyversionr   Únose.resultr   Ú
nose.suiter   Ú	nose.utilr	   Úunittest.runnerr
   r(   Úqueuer   Úwarningsr   Úior   r  Ú	getLoggerr   rt   r   r#   r$   r%   r&   r'   r   r   r,   r-   r8   rl   re   rf   r  r  r   r   r   r   Ú<module>   sX    _ÿÿ
_  sa