ó Â>Sc@s„ddlZddlZddlZddlZddlZd„Zd„Zdejfd„ƒYZ e dkr€ej ƒndS(iÿÿÿÿNcCstj|ƒdS(sTest thread to just wait a bit.N(ttimetsleep(tseconds((s,/usr/share/apport/testsuite/test_rethread.pytidlescCs||S(s"Test thread to divide two numbers.((txty((s,/usr/share/apport/testsuite/test_rethread.pytdiv stTcBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCsitjjdtddƒ}|jƒ|jƒ|jƒ|j|jƒdƒ|j|jƒdƒdS(sreturn value works properly.ttargettargsi*iiN(i*i( tapporttREThreadRtstarttjoint exc_raiset assertEqualt return_valuetexc_infotNone(tselftt((s,/usr/share/apport/testsuite/test_rethread.pyttest_return_values    cCsrtjjdtddƒ}|jƒ|jt|jƒ|jƒ|j|jƒdƒ|j|j ƒdƒdS(sAapport.REThread.REThread works if run() does not return anything.RR gà?N(gà?( R R RR t assertRaisestAssertionErrorRR RRR(RR((s,/usr/share/apport/testsuite/test_rethread.pyttest_no_return_values   cCs×tjjdtdd ƒ}|jƒ|jƒ|jt|jƒ|j|j ƒdt kƒt j |j ƒd|j ƒd|j ƒdƒ}|j|dj dƒdt|ƒƒ|j|d jd ƒƒd S( s)exception in thread is caught and passed.RR iiiiÿÿÿÿtZeroDivisionErrorsnot a ZeroDivisionError:iþÿÿÿs return x / y N(ii(R R RR R RRRt assertTrueRRt tracebacktformat_exceptiont startswithtstrtendswith(RRtexc((s,/usr/share/apport/testsuite/test_rethread.pyttest_exception)s   'cCsåtjjdtdd ƒ}|jƒ|jƒ|jt|jƒt}y|j ƒWn{t }t j ƒ}t j|d|d|dƒ}|j|djdƒdt|ƒƒ|j|d jd ƒƒnX|j|ƒd S( s+exc_raise() raises caught thread exception.RR iiiiÿÿÿÿRsnot a ZeroDivisionError:iþÿÿÿs return x / y N(ii(R R RR R RRRtFalseRtTruetsysRRRRRRR(RRtraisedteR ((s,/usr/share/apport/testsuite/test_rethread.pyttest_exc_raise7s   !'cCsItjjdtjddƒ}|jƒ|jƒ|jt|jƒdS(s+exceptions that can't be simply created are reraised correctly A unicode error takes several arguments on construction, so trying to recreate it by just passing an instance to the class, as the Python 3 reraise expression did, will fail. See lp:1024836 for details. RR sÿtasciiN(sÿsascii( R R RtencodeR R Rt UnicodeErrorR(RR((s,/usr/share/apport/testsuite/test_rethread.pyttest_exc_raise_complexJs  (t__name__t __module__RRR!R'R+(((s,/usr/share/apport/testsuite/test_rethread.pyRs   t__main__( tunittestRRR$tapport.REThreadR RRtTestCaseRR,tmain(((s,/usr/share/apport/testsuite/test_rethread.pyts 0   E