U é üeßã@sNdZddlZddlmZe e¡Zdd„ZGdd„deƒZ Gdd „d eƒZ dS) a— Result Proxy ------------ The result proxy wraps the result instance given to each test. It performs two functions: enabling extended error/failure reporting and calling plugins. As each result event is fired, plugins are called with the same event; however, plugins are called with the nose.case.Test instance that wraps the actual test. So when a test fails and calls result.addFailure(self, err), the result proxy calls addFailure(self.test, err) for each plugin. This allows plugins to have a single stable interface for all test types, and also to manipulate the test object itself by setting the `test` attribute of the nose.case.Test that they receive. éN)ÚConfigcs8‡‡fdd„}‡‡fdd„}‡‡fdd„}t||||ƒS)znCreate a property that proxies attribute ``proxied_attr`` through the local attribute ``local_attr``. cstt|ˆƒˆƒS©N)Úgetattr©Úself©Ú local_attrÚ proxied_attr©ú8/opt/hc_python/lib/python3.8/site-packages/nose/proxy.pyÚfgetszproxied_attribute..fgetcstt|ˆƒˆ|ƒdSr)Úsetattrr)rÚvaluerr r Úfsetszproxied_attribute..fsetcstt|ˆƒˆƒdSr)Údelattrrrrr r Úfdel!szproxied_attribute..fdel)Úproperty)rr Údocr rrr rr Úproxied_attributesrc@s"eZdZdZddd„Zdd„ZdS)ÚResultProxyFactoryzrFactory for result proxies. Generates a ResultProxy bound to each test and the result passed to the test. NcCs$|dkrtƒ}||_d|_d|_dS)NF)rÚconfigÚ_ResultProxyFactory__preparedÚ_ResultProxyFactory__result)rrr r r Ú__init__*s zResultProxyFactory.__init__cCsL|js,d|_|jj |¡}|dk r,||_}|jdk r<|j}t|||jdS)aReturn a ResultProxy for the current test. On first call, plugins are given a chance to replace the result used for the remaining tests. If a plugin returns a value from prepareTestResult, that object will be used as the result for all tests. TN)r)rrÚpluginsZprepareTestResultrÚ ResultProxy)rÚresultÚtestZ plug_resultr r r Ú__call__1s  zResultProxyFactory.__call__)N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr r r r r&s rc@sªeZdZdZd&dd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„ZedddƒZedd d!ƒZedd"d#ƒZedd$d%ƒZdS)'ragProxy to TestResults (or other results handler). One ResultProxy is created for each nose.case.Test. The result proxy calls plugins with the nose.case.Test instance (instead of the wrapped test case) as each result call is made. Finally, the real result method is called, also with the nose.case.Test instance as the test parameter. NcCs,|dkrtƒ}||_|j|_||_||_dSr)rrrrr)rrrrr r r rMs zResultProxy.__init__cCs t|jƒSr)Úreprrrr r r Ú__repr__UszResultProxy.__repr__cCsNt|dtƒsJt|dtƒrJt|djtfiƒ|dƒ}|d||df}|S)Néré)Ú isinstanceÚ ExceptionÚtyper)rÚerrrr r r Ú _prepareErrXszResultProxy._prepareErrcCsTt|jddƒ}||jksP||ksP|t|ddƒksPtd|jt|jƒ|t|ƒfƒ‚dS)NrZ _nose_casez4ResultProxy for %r (%s) was called with test %r (%s))rrÚAssertionErrorÚid)rrÚcaser r r Ú assertMyTestbs ÿþÿýzResultProxy.assertMyTestcCs6| |¡|j |j¡t|jdƒr2|j |j¡dS)NÚ afterTest)r/rr0rÚhasattrr©rrr r r r0ms  zResultProxy.afterTestcCs6| |¡|j |j¡t|jdƒr2|j |j¡dS)NÚ beforeTest)r/rr3rr1rr2r r r r3ss  zResultProxy.beforeTestcCs€| |¡|j}| |j|¡}|r&dS| |j|¡}|dk r@|}| |j|¡|j |j| |¡¡|j ¡s||j j r|d|_ dS)NT) r/rÚ handleErrorrZ formatErrorÚaddErrorrr+Z wasSuccessfulrÚ stopOnErrorÚ shouldStop©rrr*rZplugin_handledÚ formattedr r r r5ys zResultProxy.addErrorcCs~| |¡|j}| |j|¡}|r&dSd|j_| |j|¡}|dk rH|}| |j|¡|j |j| |¡¡|j j rzd|_ dS)NFT) r/rZ handleFailurerZpassedZ formatFailureÚ addFailurerr+rr6r7r8r r r r:ˆs zResultProxy.addFailurecCsVddlm}| |¡|j}t|tƒs.t|ƒ}| |j||df¡|j  |j|¡dS)Nr)ÚSkipTest) Znose.plugins.skipr;r/rr'r(r5rrÚaddSkip)rrÚreasonr;rr r r r<—s   zResultProxy.addSkipcCs*| |¡|j |j¡|j |j¡dSr)r/rÚ addSuccessrrr2r r r r>¢s zResultProxy.addSuccesscCs*| |¡|j |j¡|j |j¡dSr)r/rÚ startTestrrr2r r r r?§s zResultProxy.startTestcCs|j ¡dSr)rÚstoprr r r r@¬szResultProxy.stopcCs*| |¡|j |j¡|j |j¡dSr)r/rÚstopTestrrr2r r r rA¯s zResultProxy.stopTestrr7zShould the test run stop?ÚerrorszTests that raised an exceptionÚfailureszTests that failedÚtestsRunzNumber of tests run)N)rr r!r"rr$r+r/r0r3r5r:r<r>r?r@rArr7rBrCrDr r r r rCs4    ÿÿÿÿr) r"ÚloggingZ nose.configrÚ getLoggerrÚlogrÚobjectrrr r r r Ús