• File: pytest_plugin.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/__pycache__/pytest_plugin.cpython-37.pyc
  • Date Modified: 05/11/2022 10:20 AM
  • File size: 9.65 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

ka-@sddlZddlZddlZddlmZddlmZmZmZmZm	Z	m
Z
mZddlZddl
mZmZddlmZddlmZmZmZmZmZmZmZmZyddlZWnek
rdZYnXyddlZWnek
rdZYnXeeeefgeefZdd	Z d
dZ!ej"dd
Z#ej"ddZ$ej%ddZ&ej%d0ddZ'ddZ(ddZ)ddZ*ej"ddZ+ej"ddZ,ej"dd Zej"d!d"Z-ej"d#d$Z.ej"d%d&Z/ej"d'd(Z0ej"d)d*Z1ej"ej2e	eddfd+d,d-Z3ej"d.d/Z4dS)1N)Callable)Any	AwaitablerDict	GeneratorOptionalUnion)PY_37isasyncgenfunction)Application)BaseTestServer
RawTestServer
TestClient
TestServerloop_contextsetup_test_loopteardown_test_loopunused_portcCs:|jddddd|jdddd	d|jd
dddddS)Nz--aiohttp-fast
store_trueFz*run tests faster by disabling extra checks)actiondefaulthelpz--aiohttp-loopZstorepyloopz:run tests with specific loop: pyloop, uvloop, tokio or allz--aiohttp-enable-loop-debugzenable event loop debug mode)Z	addoption)parserrH/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/pytest_plugin.pypytest_addoption$srcsb|jtrdntr$dndSdd|jkrH|jd7_dfdd}||_dS)zjSet up pytest fixture.

    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFNrequest)rcsv|d}r|d=d|jkr$td|drb||fdd}||S||SdS)Nrloopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.cs(yStk
r"YnXdS)N)run_until_complete	__anext__StopAsyncIterationr)_loopgenrr	finalizerdsz8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer)fixturenames	ExceptionZgetfixturevalueZaddfinalizerr r!)argskwargsrr%)funcis_async_gen
strip_request)r#r$rwrapperOs



z%pytest_fixture_setup.<locals>.wrapper)r*r
asyncioiscoroutinefunctionargnames)Z
fixturedefr-r)r*r+r,rpytest_fixture_setup9s

 r1cCs|jdS)z--fast config optionz--aiohttp-fast)config	getoption)rrrrfastrsr4cCs|jdS)z!--enable-loop-debug config optionz--aiohttp-enable-loop-debug)r2r3)rrrr
loop_debugxsr5c	cs`tjddJ}dVdd|D}|rRtdt|t|dkrBdnd	d
|WdQRXdS)zContext manager which checks for RuntimeWarnings.

    This exists specifically to
    avoid "coroutine 'X' was never awaited" warnings being missed.

    If RuntimeWarnings occur in the context a RuntimeError is raised.
    T)recordNcSs"g|]}|jtkrdj|dqS)z#{w.filename}:{w.lineno}:{w.message})w)categoryRuntimeWarningformat).0r7rrr
<listcomp>sz,_runtime_warning_context.<locals>.<listcomp>z{} Runtime Warning{},
{}rs
)warningscatch_warningsRuntimeErrorr:lenjoin)	_warningsZrwrrr_runtime_warning_context~s	rFFccs(|r|Vnt}|Vt||ddS)zPassthrough loop context.

    Sets up and tears down a loop unless one is passed in via the loop
    argument when it's passed straight through.
    )r4N)rr)rr4rrr_passthrough_loop_contexts
rGcCs(||r$t|r$t|||SdS)z%Fix pytest collecting for coroutines.N)Zfuncnamefilterr.r/listZ
_genfunctions)Z	collectornameobjrrrpytest_pycollect_makeitemsrKc
sjd}tjrjdp0jdd}tFt||d.}fddj	j
D}|jf|WdQRXWdQRXdSdS)	zBRun coroutines in an event loop instead of a normal function call.z--aiohttp-fast
proactor_looprN)r4csi|]}j||qSr)funcargs)r;arg)
pyfuncitemrr
<dictcomp>sz&pytest_pyfunc_call.<locals>.<dictcomp>T)
r2r3r.r/ZfunctionrMgetrFrGZ_fixtureinfor0r rJ)rOr4Z
existing_loopr#Ztestargsr)rOrpytest_pyfunc_calls
&rRcCsd|jkrdS|jjj}dtji}tdk	r4tj|d<tdk	rFtj|d<|dkrRd}i}x\|	dD]N}|
d}|d	}||kr|rbtd
|t
|fnqb||||<qbW|jdt
|t
|ddS)Nloop_factoryruvlooptokioallzpyloop,uvloop?,tokio?,?z ?z&Unknown loop '%s', available loops: %s)Zids)r&r2ZoptionZaiohttp_loopr.ZDefaultEventLoopPolicyrTZEventLoopPolicyrUsplitendswithstrip
ValueErrorrHkeysZparametrizevalues)ZmetafuncZloopsZavail_factoriesZ	factoriesrIZrequiredrrrpytest_generate_testss.





r_c	csH|}t|t|d$}|r*|dt||VWdQRXdS)z%Return an instance of the event loop.)r4TN)r.set_event_loop_policyrZ	set_debugset_event_loop)rSr4r5policyr#rrrrs


rc	csRtst}tj|_nt}t|t|j}t	||VWdQRXdS)N)
r	r.Zget_event_loop_policyZProactorEventLoopZ
_loop_factoryZWindowsProactorEventLoopPolicyr`rZnew_event_loopra)rbr#rrrrLs


rLcCstjdtdd|S)Nz3Deprecated, use aiohttp_unused_port fixture instead)
stacklevel)r@warnDeprecationWarning)aiohttp_unused_portrrrrs
rcCstS)z1Return a port that is unused on the current host.)_unused_portrrrrrgsrgc#s@gddfdd
}|Vddfdd}|dS)z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    N)portcs4t||d}|jfdi|IdH||S)N)rir)rstart_serverappend)Zapprir)server)rserversrrgos
zaiohttp_server.<locals>.go)returncs xrIdHqWdS)N)popcloser)rmrrfinalizesz aiohttp_server.<locals>.finalize)r )rrnrrr)rrmraiohttp_servers
rscCstjdtdd|S)Nz.Deprecated, use aiohttp_server fixture insteadrc)rd)r@rerf)rsrrrtest_server"s
rtc#s@gddfdd
}|Vddfdd}|dS)zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    N)rics4t||d}|jfdi|IdH||S)N)rir)rrjrk)Zhandlerrir)rl)rrmrrrn4s
zaiohttp_raw_server.<locals>.go)rocs xrIdHqWdS)N)rprqr)rmrrrr<sz$aiohttp_raw_server.<locals>.finalize)r )rrnrrr)rrmraiohttp_raw_server,s
rucCstjdtdd|S)Nz2Deprecated, use aiohttp_raw_server fixture insteadrc)rd)r@rerf)rurrrraw_test_serverCs
rv)rroc#sbgddtttftttttfttdfdd}|Vddfdd}|dS)	zFactory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    N)
server_kwargs)__paramr(rwr)rocst|tr.t|ttfs.|f||}i}n|r:tdt|trv|pJi}t|fdi|}t|fdi|}n0t|trt|fdi|}ntdt||	IdH
||S)Nzargs should be emptyrzUnknown argument type: %r)
isinstancerrr
AssertionErrorrrr\typerjrk)rxrwr(r)rlZclient)clientsrrrrn[s


zaiohttp_client.<locals>.go)rocs xrIdHqWdS)N)rprqr)r|rrrrysz aiohttp_client.<locals>.finalize)	rrr
rrrstrrr )rrnrrr)r|rraiohttp_clientOs
 r~cCstjdtdd|S)Nz.Deprecated, use aiohttp_client fixture insteadrc)rd)r@rerf)r~rrrtest_clients
r)F)5r.
contextlibr@Zcollections.abcrtypingrrrrrrZpytestZaiohttp.helpersr	r
Zaiohttp.webrZ
test_utilsr
rrrrrrrrhrTImportErrorrUZ
AiohttpClientrr1Zfixturer4r5contextmanagerrFrGrKrRr_rrLrgrsrtrurvZAbstractEventLoopr~rrrrr<module>sN$(

9"

.