ϪfdZddlmZddlmZmZddlZddlm Z ddl m Z m Z Gd d ejjjZGd d Zy) z0 Tests for L{twisted.application.runner._exit}. )StringIO)OptionalUnionN)_exit) ExitStatusexitc8eZdZdZddZddZddZddZddZy) ExitTestsz Tests for L{exit}. Ncdt|_|jtd|jy)Nsysexit) DummyExitr patchrselfs K/usr/lib/python3/dist-packages/twisted/application/runner/test/test_exit.pysetUpzExitTests.setUpsK  5)TYY/cjd}t||j|jj|y)zR L{exit} given an L{int} status code will pass it to L{sys.exit}. iN)r assertEqualargrstatuss rtest_exitStatusIntzExitTests.test_exitStatusInts( V  /rctj}t||j|jj|j y)zu L{exit} given a L{ValueConstant} status code passes the corresponding value to L{sys.exit}. N)r EX_CONFIGr rrvaluers rtest_exitConstantzExitTests.test_exitConstant!s2 %% V   5rct}|jtd|d}td||j |j |dzy)zq L{exit} given a status code of zero (C{0}) writes the given message to standard output. stdout Hello, world.r Nrrrr rgetvalueroutmessages rtest_exitMessageZerozExitTests.test_exitMessageZero*sD j 5(C(! Q 48rct}|jtd|d}td||j |j |dzy)zj L{exit} given a non-zero status code writes the given message to standard error. stderrr"@r#Nr$r&s rtest_exitMessageNonZeroz!ExitTests.test_exitMessageNonZero7sD j 5(C(! R 48rreturnN) __name__ __module__ __qualname____doc__rrrr)r-rrr r s 006 9 9rr c:eZdZdZddZddeeeefddfdZ y) rzv Stub for L{sys.exit} that remembers whether it's been called and, if it has, what argument it was given. r/Ncd|_y)NF)exitedrs r__init__zDummyExit.__init__Ks  rrc<|jrJ||_d|_y)NT)r7r)rrs r__call__zDummyExit.__call__Ns;; rr.)N) r0r1r2r3r8rrintstrr:r4rrrrEs, HU38_5rr)r3iortypingrrtwisted.trial.unittesttwistedrunnerrr r trialunittestTestCaser rr4rrrEsB"$29 &&//29j  r