Viewing File: /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/pytest_plugin.cpython-38.pyc

U

'7`+@sddlZddlZddlZddlmZddlZddlmZmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZzddlZWnek
rdZYnXzddlZWnek
rdZYnXddZd	d
ZejddZejd
dZejddZejd.ddZddZ ddZ!ddZ"ejddZ#ejddZ$ejddZejd d!Z%ejd"d#Z&ejd$d%Z'ejd&d'Z(ejd(d)Z)ejd*d+Z*ejd,d-Z+dS)/N)Callable)PY_37isasyncgenfunction)Application)BaseTestServer
RawTestServer
TestClient
TestServerloop_contextsetup_test_loopteardown_test_loopunused_portcCs:|jddddd|jdddd	d|jd
dddddS)N--aiohttp-fast
store_trueFz*run tests faster by disabling extra checks)actiondefaulthelpz--aiohttp-loopZstorepyloopz:run tests with specific loop: pyloop, uvloop, tokio or all--aiohttp-enable-loop-debugzenable event loop debug mode)Z	addoption)parserrH/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/pytest_plugin.pypytest_addoption!s$rcsb|jtrdntr$dndSdd|jkrH|jd7_dfdd}||_dS)zS
    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFNrequestrcsv|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*zWStk
r$YnXdSN)run_until_complete	__anext__StopAsyncIterationr_loopgenrr	finalizer`sz8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer)fixturenames	ExceptionZgetfixturevalueZaddfinalizerrr)argskwargsrr$funcZis_async_genZ
strip_requestr!rwrapperKs



z%pytest_fixture_setup.<locals>.wrapper)r*rasyncioiscoroutinefunctionargnames)Z
fixturedefr+rr)rpytest_fixture_setup6s

 r/cCs|jdS)z--fast config optionrconfig	getoptionrrrrfastnsr3cCs|jdS)z!--enable-loop-debug config optionrr0rrrr
loop_debugtsr4c	cs`tjddJ}dVdd|D}|rRtdt|t|dkrBdnd	d
|W5QRXdS)z
    Context manager which checks for RuntimeWarnings, 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).0r6rrr
<listcomp>s
z,_runtime_warning_context.<locals>.<listcomp>z{} Runtime Warning{},
{}rs
)warningscatch_warningsRuntimeErrorr9lenjoin)	_warningsZrwrrr_runtime_warning_contextzsrEFccs(|r|Vnt}|Vt||ddS)z{
    setups and tears down a loop unless one is passed in via the loop
    argument when it's passed straight through.
    r3N)rr
)rr3rrr_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|W5QRXW5QRXdSdS)	zL
    Run coroutines in an event loop instead of a normal function call.
    r
proactor_looprNrFcsi|]}|j|qSr)funcargs)r:arg
pyfuncitemrr
<dictcomp>sz&pytest_pyfunc_call.<locals>.<dictcomp>T)
r1r2r,r-ZfunctionrMgetrErGZ_fixtureinfor.rrJ)rPr3Z
existing_loopr"ZtestargsrrOrpytest_pyfunc_calls
&rScCsd|jkrdS|jjj}dtji}tdk	r4tj|d<tdk	rFtj|d<|dkrRd}i}|	dD]N}|
d}|d	}||kr|r`td
|t
|fnq`||||<q`|jdt
|t
|ddS)Nloop_factoryruvlooptokioallzpyloop,uvloop?,tokio?,?z ?z&Unknown loop '%s', available loops: %s)Zids)r%r1ZoptionZaiohttp_loopr,ZDefaultEventLoopPolicyrUZEventLoopPolicyrVsplitendswithstrip
ValueErrorrHkeysZparametrizevalues)ZmetafuncZloopsZavail_factoriesZ	factoriesrIZrequiredrrrpytest_generate_testss8







r`c	csH|}t|t|d$}|r*|dt||VW5QRXdS)z%Return an instance of the event loop.rFTN)r,set_event_loop_policyrZ	set_debugset_event_loop)rTr3r4policyr"rrrrs


rc	csRtst}tj|_nt}t|t|j}t	||VW5QRXdSr)
rr,Zget_event_loop_policyZProactorEventLoopZ
_loop_factoryZWindowsProactorEventLoopPolicyrarZnew_event_looprb)rcr"rrrrLs


rLcCstjdtdd|S)Nz3Deprecated, use aiohttp_unused_port fixture instead
stacklevelr?warnDeprecationWarning)aiohttp_unused_portrrrrsrcCstS)z1Return a port that is unused on the current host.)_unused_portrrrrrjsrjc#s:gddfdd
}|Vfdd}|dS)z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    Nportcs4t||d}|jfdi|IdH||SNrlr)r
start_serverappend)Zapprmr(serverrserversrrgos
zaiohttp_server.<locals>.gocsrIdHqdSrpopcloserrsrrfinalizesz aiohttp_server.<locals>.finalizerrrtryrrrraiohttp_server	s
r|cCstjdtdd|S)Nz.Deprecated, use aiohttp_server fixture insteadrdrerg)r|rrrtest_server sr}c#s:gddfdd
}|Vfdd}|dS)zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    Nrlcs4t||d}|jfdi|IdH||Srn)rrorp)Zhandlerrmr(rqrrrrrt2s
zaiohttp_raw_server.<locals>.gocsrIdHqdSrrurrxrrry:sz$aiohttp_raw_server.<locals>.finalizerzr{rrrraiohttp_raw_server*s
r~cCstjdtdd|S)Nz2Deprecated, use aiohttp_raw_server fixture insteadrdrerg)r~rrrraw_test_serverAsrc#s:gddfdd
}|Vfdd}|dS)zFactory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    N)
server_kwargscst|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)
isinstancerrrAssertionErrorr
r	r]typerorp)Z__paramrr'r(rqZclientclientsrrrrtUs"


zaiohttp_client.<locals>.gocsrIdHqdSrrur)rrrrynsz aiohttp_client.<locals>.finalizerzr{rrraiohttp_clientKs
rcCstjdtdd|S)Nz.Deprecated, use aiohttp_client fixture insteadrdrerg)rrrrtest_clientusr)F),r,
contextlibr?Zcollections.abcrZpytestZaiohttp.helpersrrZaiohttp.webrZ
test_utilsrrr	r
rrr
rrkrUImportErrorrVrr/Zfixturer3r4contextmanagerrErGrKrSr`rrLrjr|r}r~rrrrrrr<module>s`(

8


"



	


	

	
)
Back to Directory File Manager