Ϫf dZddlmZddlZddlZddlmZddlmZddl m Z m Z ddl m Z ddlmZdd lmZdd lmZdd lmZed d Zed dZeddZed dZGddeZGddeZGddeZy)z( Tests for L{twisted.internet.default}. ) annotationsN)Callable)default)_getInstallFunctioninstall) IReactorCore) NoReactor) requireModule)Platform)SynchronousTestCaseposixotherlinux2ntwin32darwinc(eZdZdZddZddZddZy)PollReactorTestsz Tests for the cases of L{twisted.internet.default._getInstallFunction} in which it picks the poll(2) or epoll(7)-based reactors. cttdr|j|jdy|j|jdy)zz Assert the given function will install the poll() reactor, or select() if poll() is unavailable. pollztwisted.internet.pollreactortwisted.internet.selectreactorN)hasattrselect assertEqual __module__selfrs D/usr/lib/python3/dist-packages/twisted/internet/test/test_default.py assertIsPollzPollReactorTests.assertIsPoll!s< 66 "   W//1O P   W//1Q RcDtt}|j|y)z L{_getInstallFunction} chooses the poll reactor on arbitrary Unix platforms, falling back to select(2) if it is unavailable. N)runixrrs r test_unixzPollReactorTests.test_unix+s &d+ '"r ctt}td|j|y|j |j dy)zu L{_getInstallFunction} chooses the epoll reactor on Linux, or poll if epoll is unavailable. ztwisted.internet.epollreactorN)rlinuxr rrrrs r test_linuxzPollReactorTests.test_linux3s? &e, 8 9 A   g &   W//1P Qr N)rzCallable[..., object]returnNoner'r()__name__r __qualname____doc__rr#r&r rrrs S# Rr rc eZdZdZddZddZy)SelectReactorTestsz Tests for the cases of L{twisted.internet.default._getInstallFunction} in which it picks the select(2)-based reactor. cZtt}|j|jdy)zM L{_getInstallFunction} chooses the select reactor on macOS. rN)rosxrrrs rtest_osxzSelectReactorTests.test_osxEs%&c* ++-MNr cZtt}|j|jdy)zO L{_getInstallFunction} chooses the select reactor on Windows. rN)rwindowsrrrs r test_windowszSelectReactorTests.test_windowsLs%&g. ++-MNr Nr))r*rr+r,r2r5r-r rr/r/?s OOr r/c eZdZdZddZddZy)InstallationTestsz7 Tests for actual installation of the reactor. ct5t|jdtjdddy#1swYyxYw)z0 L{install} installs a reactor. ztwisted.internet.reactorN)r rassertInsysmodules)rs r test_installzInstallationTests.test_installYs:[ C I MM4ckk B C C Cs +?Acgdfd }|jtd|t5ddlm}|j t j||jdgdddy#1swYyxYw)zr Importing L{twisted.internet.reactor} installs the default reactor if none is installed. c:jdtS)NT)appendr) installedsr installerz1InstallationTests.test_reactor..installerhs   T "9 r rr)reactorTN)r'object) patchrr twisted.internetrB assertTruer providedByr)rrArBr@s @r test_reactorzInstallationTests.test_reactorasg !#   7Iy1 [ 0 0 OOL33G< =   Y /  0 0 0s >A22A;Nr))r*rr+r,r<rHr-r rr7r7TsC0r r7)r, __future__rrr:typingrrErtwisted.internet.defaultrrtwisted.internet.interfacesrtwisted.internet.test.test_mainr twisted.python.reflectr twisted.python.runtimer twisted.trial.unittestr r"r%r4r1rr/r7r-r rrQs# $A450+6!(# 4 !w!!R*!RHO,O*0+0r