a c@sUddlmZddlmZmZddlmZmZmZm Z m Z m Z m Z ddl Z ddlZddlmZddlmZmZddlmZerdd lmZdae eed <ee eeeeffd d d Zeeeeefe eedfdddZdddddZeeddddZe j ddeeeddddZ!e j ddee e"dddZ#e j$ed eed!d"d#Z%e j$eed$d%d&Z&e j$eeeefd$d'd(Z'dS)))contextmanager)isasyncgenfunctioniscoroutinefunction) TYPE_CHECKINGAnyDict GeneratorOptionalTuplecastN)FixtureRequest)get_all_backends get_asynclib) TestRunner)Config_current_runner)backendreturncCsjt|tr|ifSt|tr^t|dkr^t|dtr^t|dtr^ttttttff|St ddS)Nrr z@anyio_backend must be either a string or tuple of (string, dict)) isinstancestrtuplelendictr r rr TypeError)rr`/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/anyio/pytest_plugin.pyextract_backend_and_optionss  r) backend_namebackend_optionsrc cstrtVdSt|}d}tjddur6tj|}zZ|p>i}|jfi|}|a|VWdn1sp0YWda|rtj|nda|rtj|0dSN)rrsniffioZcurrent_async_library_cvargetsetrreset)rr Zasynclibtokenrunnerrrr get_runners$ &r(r)configrcCs|dddS)NmarkerszManyio: mark the (coroutine function) test to be run asynchronously via anyio.)Zaddinivalue_line)r)rrrpytest_configure6sr+) fixturedefrequestrcsTfdd}|jts$trPd|jvrPd|jv||_sP|jd7_dS)Nc?spt|\}}r||d<t||:}tr@||EdHn||VWdn1sb0YdS)N anyio_backend)rr(rZrun_asyncgen_fixtureZ run_fixture)r.argskwargsrr r'funcZhas_backend_argrrwrapper?s  z%pytest_fixture_setup..wrapperr.r.)r2rrZ fixturenamesargnames)r,r-r3rr1rpytest_fixture_setup>s   r6T)Ztryfirst) collectornameobjrcCsj|||rft|dr|jjn|}t|rf|d}t|dd}|sVtdd|Drftj d|dS)N hypothesisanyioZ pytestmarkrcss|]}|jdkVqdS)r;N)r8).0markerrrr \z,pytest_pycollect_makeitem..r.) Zistestfunctionhasattrr: inner_testrZget_closest_markergetattranypytestmarkZ usefixtures)r7r8r9Z inner_funcr=Z own_markersrrrpytest_pycollect_makeitemUs   rF) pyfuncitemrcstddfdd }|jd}|rt|\t|jdrl|jjjj|jkrht rh||jj_dSt |jr|jfdd|j j D}t }| |j|Wdn1s0YdSdS) N)r0rcs:t}||Wdn1s,0YdSr!)r(run_test)r0r')rr original_funcrrrun_with_hypothesisbs z/pytest_pyfunc_call..run_with_hypothesisr.r:csi|]}||qSrr)r<arg)funcargsrr ur?z&pytest_pyfunc_call..T)rrLr#rr@r9r:rA __qualname__rZ _fixtureinfor5r(rH)rGrJrZtestargsr'r)rr rLrIrpytest_pyfunc_call`s"        ,rO)params)r-rcCs|jSr!)param)r-rrrr.~sr.)r.rcCst|tr|S|dSdS)Nrrrr4rrranyio_backend_names rScCst|triS|dSdS)Nr rRr4rrranyio_backend_optionss rT)( contextlibrinspectrrtypingrrrrr r r rDr"Z_pytest.fixturesr Z_core._eventlooprrabcrZ_pytest.configrr__annotations__objectrrr(r+r6ZhookimplrFboolrOZfixturer.rSrTrrrrs6$