U é üeJã@sndZddlZddddddd d gZGd d„deƒZd d„Zd d„Zdd„Zdd„Zddd„Z dd „Z dd „Z dS)z8Tools not exempt from being descended into in tracebackséNÚmake_decoratorÚraisesÚ set_traceÚtimedÚ with_setupÚ TimeExpiredÚistestÚnottestc@s eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©r r úC/opt/hc_python/lib/python3.8/site-packages/nose/tools/nontrivial.pyr scs‡fdd„}|S)z¨ Wraps a test decorator so as to properly replicate metadata of the decorated function, including nose's additional stuff (namely, setup and teardown). csntˆdƒrˆj}nˆj}ˆj|_ˆj|_ˆj|_t|dƒsDˆjj|_z ||_Wnt k rh||_YnX|S)NÚcompat_func_nameÚcompat_co_firstlineno) Úhasattrrr Ú__dict__Ú__doc__r Ú__code__Úco_firstlinenorÚ TypeError)ÚnewfuncÚname©Úfuncr rÚdecorates     z make_decorator..decorater )rrr rrrs cs&d dd„ˆDƒ¡‰‡‡fdd„}|S)a‘Test must raise one of expected exceptions to pass. Example use:: @raises(TypeError, ValueError) def test_raises_type_error(): raise TypeError("This test passes") @raises(Exception) def test_that_fails_by_passing(): pass If you want to test many assertions about exceptions in a single test, you may want to use `assert_raises` instead. z or cSsg|] }|j‘qSr )r )Ú.0Úer r rÚ 7szraises..cs(ˆj‰‡‡‡‡fdd„}tˆƒ|ƒ}|S)NcsHzˆ||ŽWn ˆk r"Yn"‚YnXdˆˆf}t|ƒ‚dS)Nz%s() did not raise %s)ÚAssertionError)ÚargÚkwÚmessage)Ú exceptionsrrÚvalidr rr:s z)raises..decorate..newfunc)r r©rr©r#r$)rrrr8s zraises..decorate)Újoin)r#rr r&rr'scCs6ddl}ddl}|j}|j|_| ¡ | ¡j¡dS)zÂCall pdb.set_trace in the calling frame, first restoring sys.stdout to the real output stream. Note that sys.stdout is NOT reset to whatever it was before the call once pdb is done! rN)ÚpdbÚsysÚstdoutÚ __stdout__ZPdbrÚ _getframeÚf_back)r(r)r*r r rrIs cs‡fdd„}|S)z•Test must finish within specified time limit to pass. Example use:: @timed(.1) def test_that_fails(): time.sleep(.2) cs‡‡fdd„}tˆƒ|ƒ}|S)Ncs6t ¡}ˆ||Ž}t ¡}||ˆkr2tdˆƒ‚|S)NzTime limit (%s) exceeded)Útimer)r r!ÚstartÚresultÚend)rÚlimitr rr_s    z(timed..decorate..newfunc)rr%©r2rrr^s ztimed..decorater )r2rr r3rrUs cCs||fdd„}|S)aDecorator to add setup and/or teardown methods to a test function:: @with_setup(setup, teardown) def test_something(): " ... " Note that `with_setup` is useful *only* for test functions, not for test methods or inside of TestCase subclasses. csdˆr0t|dƒr*|j‰‡‡fdd„}||_nˆ|_ˆr`t|dƒrZ|j‰‡‡fdd„}||_nˆ|_|S)NÚsetupcsˆƒˆƒdS©Nr r )Ú_old_sr4r rÚ_sysz(with_setup..decorate.._sÚteardowncsˆƒˆƒdSr5r r )Ú_old_tr8r rÚ_t‚sz(with_setup..decorate.._t)rr4r8)rr4r8r7r:r )r6r9r4r8rrus  zwith_setup..decorater )r4r8rr r rrks cCs d|_|S)z5Decorator to mark a function or method as a test T©Z__test__rr r rrŒscCs d|_|S)z;Decorator to mark a function or method as *not* a test Fr;rr r rr “s)NN) rr.Ú__all__rrrrrrrrr r r r rÚs ÿ"  !