bg~ 4dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddl mZddl mZddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl*m,Z,ddl*m-Z-ddl*m.Z.dd l/m0Z0dd!l/m1Z1dd"l2m3Z3dd#l2m4Z4erdd$l5m6Z6d%e%d&dfd'Z7d(e8d&e8fd)Z9d*ed+e ed,geee:e ffd&ee:e ffd-Z;d*ed&ee:e ffd.Zd/d,d&e?fd2Z@d(e d&e?fd3ZAd4e d*ed&ee?fd5ZBd6eejCd*ed&dfd7ZDGd8d9ZEGd:d;eFZGGd<d=eHZIejJGd>d?e e e8fZKeGd@d,ejLZMdAe8d&e8fdBZNdCdDdEe dFe8dGe?d&ee ee8ffdHZOdS)JzHCore implementation of the testing process: init, session, runtest loop.N)Path)Callable)Dict) FrozenSet)Iterator)List)Optional)Sequence)Set)Tuple)Type) TYPE_CHECKING)Union)nodes)final)overload)Config) directory_arg)ExitCode)hookimpl)PytestPluginManager) UsageError)Parser)FixtureManager)exit absolutepath) bestrelpath fnmatch_ex)visit) CollectReport) TestReport)collect_one_node) SetupState)Literalparserreturnc |dddgd|dddg|dd }|d d d d dd|d}|dddd|ddd|dddtd dd |d!d"d#|d$d"d%|d&d"d'|d(d)d*t d+d,-|d.d"d/d0d12|d3dd4d56|d7d8}|d9d:d;d"d<|d=d"d>|d?dd@dAB|dCdd@dDB|dEddFdGB|dHdIddJt jtdHKdLM|dNd"dOd/dPQ|dRdSd"dTd/dUQ|dVd"dWd/dXQ|dYdZgd[d\d]^|d_d`}|dadbdtdJdcddS)eN norecursedirsz)Directory patterns to avoid for recursionargs) z*.eggz.*_darcsbuildCVSdist node_modulesvenvz{arch})typedefault testpathszZDirectories to search for tests when no files or directories are given on the command linegeneralzRunning and selection optionsz-xz --exitfirst store_constmaxfailz,Exit instantly on first error or failed test)actiondestconsthelpzpytest-warningsz-Wz--pythonwarningsappendz.is_ancestors 5==4 $$rd)argparseArgumentTypeErrorrboolcwdabsoluteresolve)rJmsgrjs rbr`r`s cC .(---%$%t%%%%%{48::tDzz224455.(---{48::%%''d););)=)=>>.(--- KrdconfigdoitSessionc $t|}tj|_d} |d}|j|d}|||pd|_n#t$rtj |_t$rtj |_Ynttjf$rtjj}tj}t)|jtjrR|jj |jj}|dkr4t.j|jd|jjd|j|||_Ynt:$rtj|_tjj} |||j t)|jtBrt.jd nf#tj$rT}|j |j|_t.jtE|j#d|dYd}~nd}~wwxYwYnwxYwd}tIj%|j&|dkr |j'||j nf#tj$rT}|j |j|_t.jtE|j#d|dYd}~nd}~wwxYw|(n#d}tIj%|j&|dkr |j'||j nf#tj$rT}|j |j|_t.jtE|j#d|dYd}~nd}~wwxYw|(wxYw|jS) zSkeleton command line program.rr8sessionNz:  )excinfoz(mainloop: caught unexpected SystemExit! )rw exitstatus))rt from_configrOKr{ _do_configurehookpytest_sessionstartr USAGE_ERRORFailed TESTS_FAILEDKeyboardInterruptr Exception_pytest_code ExceptionInfo from_current INTERRUPTED isinstancevalue returncodesysstderrwritetypenamerqpytest_keyboard_interrupt BaseExceptionINTERNAL_ERRORnotify_exceptionoption SystemExitr2__name__oschdir startpathpytest_sessionfinish_ensure_unconfigure)rrrsrw initstaterzr{excs rb wrap_sessionrsc!!&))G!GI0% R  " " "I K + +G + < < <I!%fg!6!6!;!G     !)!5G   7 7 7!)!6G   !4>2 , , ,m1>>@@G/7/CJ'-88 S=+7!(!9Jq==J$$(8%Q%QGM>@@G R''??? gmZ88RJ$$%PQQQ > C C C>-),G&   DII$6!A!A#!A!A!ABBBBBBBB C R "### >> C 00#0B1> C C C>-),G&   DII$6!A!A#!A!A!ABBBBBBBB C ""$$$$ "### >> C 00#0B1> C C C>-),G&   DII$6!A!A#!A!A!ABBBBBBBB C ""$$$$  sAA86M86J.M1CJM =JH#:JJ,A I;6J;JJMJM+!K L0A L++L0"P+!N  P O0A O+&P+O00Pc,t|tSN)r_mainrrs rbpytest_cmdline_mainr<s  & &&rdrwc|j||j||jr tjS|jdkr tjSdS)z[Default command line protocol for initialization, session, running tests and reporting.rvrN)rpytest_collectionpytest_runtestloop testsfailedrrtestscollectedNO_TESTS_COLLECTED)rrrws rbrr@sf K!!'!222 K""7"333+$$  1 $ $** 4rdc.|dSr)perform_collectrvs rbrrMs rdc|jr=|jjjs,|d|j|jdkrdndfz|jjjrdSt |jD]\}}|dzt|jkr|j|dznd}|jj |||j r| |j |j r||j dS)Nz%d error%s during collectionr8sT)itemnextitem)rrrrrF Interrupted collectonly enumerateitemslenrpytest_runtest_protocol shouldfailr shouldstop)rwirrs rbrrQs$ 7>#8#V !! *"7+>!+C+CCCL M   ~(tW]++::4+,q53w}3E3E+E+E7=Q''4 00dX0NNN   5..!344 4   :%%g&899 9 : 4rdc |tjdrdnd} |sdSn#t $rYdSwxYwdt fd|DS)zAttempt to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the appropriate activate script.winScriptsbinF)activatez activate.cshz activate.fishActivatez Activate.batz Activate.ps1c3*K|] }|jvVdSrname).0fname activatess rb z_in_venv..vs*EE5uzY&EEEEEErd)joinpathrplatform startswithis_dirOSErroranyiterdir)rJbindirrs @rb_in_venvres]] (?(?(F(FQ99E R RF}} 5  uuI EEEEFNN4D4DEEE E EEsA AAcollection_pathc|dj|j}|pg}|d}|r|d|D|vrdS|dj|j}|pg}|d}|r|d|Dt fd |DrdS|d }|st rdSr2|d }t fd |DrdSdS) Ncollect_ignore)rJrootpathignorec34K|]}t|VdSrrrxs rbrz(pytest_ignore_collect..s(@@LOO@@@@@@rdTcollect_ignore_glob ignore_globc34K|]}t|VdSrrrs rbrz(pytest_ignore_collect..s(DDLOODDDDDDrdc3vK|]3}tjtt|V4dSr)fnmatchr])rglobrs rbrz(pytest_ignore_collect..s= U U7?3//T ; ; U U U U U UrdrQr*c38K|]}t|VdSrr)rpatrs rbrz(pytest_ignore_collect..s-MMCz#//MMMMMMrd) _getconftest_pathlistparentr getoptionextendrrrgetini)rrr ignore_paths excludeopt ignore_globsexcludeglobopt allow_in_venvnorecursepatternss` rbpytest_ignore_collectrys//50L %2L!!(++JA@@Z@@@@@@,&&t//O$:V_0L %2L%%m44NEDD^DDDDDD U U U U U U UUUt$$%<==M Xo66t"MM/:: MMMM;LMMM M M 4 4rdrc>t|dpg}|sdSg}g}|D]G}|j|r||2||H|r$|j|||dd<dSdS)Ndeselect)r)tuplernodeidrr=rpytest_deselected)rrrdeselect_prefixes remaining deselectedcolitems rbpytest_collection_modifyitemsrsf..z::@bAA IJ&& > $ $%6 7 7 &   g & & & &   W % % % % %%J%777aaardc*eZdZdeddfdZdefdZdS) FSHookProxypmr(Nc"||_||_dSr)r remove_mods)selfrrs rb__init__zFSHookProxy.__init__s&rdrc\|j||j}||j|<|S)N)remove_plugins)rsubset_hook_callerr__dict__)rrrs rb __getattr__zFSHookProxy.__getattr__s0 G & &tDeZdZUeZeZeed<eed<ee e fed<de ddffd Z e de ddfdZdefd Zedefd Zd edefd Zed d&dZed deeefddfdZeZdeedfdefdZd'dZdddefdZ d(dededee j!fdZ"e# d)de$eedddee j%fd Z&e# d)de$eededeee j%e j!ffd!Z& d*de$eededeee j%e j!ffd"Z&de'ee j%e j!ffd#Z(d$ee j%e j!fde'e j%fd%Z)xZ*S)+rt _setupstate_fixturemanagerr{rrr(Nczt|jdd||dd|_d|_d|_d|_|jj d|_t|_ t|j|_ |jj|ddS)Nr)rJfspathrrrrwrrFrIrwr)superrrrrrrtracerootget frozenset _initialpathsr _bestrelpathcacherr pluginmanagerregister)rrr __class__s rbrzSession.__init__s     ,1,1\&**<88 .7kk2DV_2U2U !**4i*@@@@@rdc2||}|S)Nr)_create)clsrrrws rbr|zSession.from_configs;;f;55rdcfd|jj|jt|dd|j|jfzS)Nz6<%s %s exitstatus=%r testsfailed=%d testscollected=%d>r{z)r!rrgetattrrrrs rb__repr__zSession.__repr__s=G N # I D, 2 2     K   rdc$|jjjS)zQThe path from which pytest was invoked. .. versionadded:: 7.0.0 )rrinvocation_paramsrMr's rbrzSession.startpaths {,00rd node_pathc|j|Sr)r)rr+s rb_node_location_to_relpathz!Session._node_location_to_relpaths%i00rdT)tryfirstc|jr||j|jr||jdSr)rrrrr's rbpytest_collectstartzSession.pytest_collectstartsJ ? /++do.. . ? 4""4?33 3 4 4rdreportc|jrXt|dsJ|xjdz c_|jd}|r |j|krd|jz|_dSdSdSdSdS)Nwasxfailr8r7zstopping after %d failures)failedhasattrrrrgetvaluer)rr1r7s rbpytest_runtest_logreportz Session.pytest_runtest_logreports = T!$BR"S  T T T T T T66rdrJos.PathLike[str]c`t|tr|nt|}||jvSr)rrr)rrJpath_s rb isinitpathzSession.isinitpaths."4..>DJJ***rdrcnt|tr|nt|}|jj}|||jd|jj}|j|}|r ddl m }|t||}n |jj }|S)NrT)rr8)PathAwareHookProxy) rrrrr_getconftestmodulesrr_conftest_plugins difference config.compatr=rr)rrrJrmy_conftestmodulesrr=proxys rb gethookproxyzSession.gethookproxys#FD11CvvtF|| [ & 33  K ! !, / /[)4   *556HII  % 9 9 9 9 9 9&&{2{'C'CDDEEK$E rddirentryzos.DirEntry[str]c|jdkrdSt|j}||j}|||jrdSdS)N __pycache__FrrrT)rrrJrDrrrr)rrErihooks rb_recursezSession._recurse5s_ =M ) )5hm$$!!&-00  & &vdk & R R 5trd handle_dupesc(|sVJd||||||}||s|||jrdS|rH|j d}|s,|jj j }||vrdS| || ||S)Nz9{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})rHrrP) file_pathr)is_fileformatrexists is_symlinkrDr;rrrrr_duplicatepathsaddpytest_collect_file)rrrKrIrPduplicate_pathss rb _collectfilezSession._collectfile>s NN    F M M FMMOOV]]__f6G6G6I6I    !!&))v&& **6$+*VV r  0![223CDDN! 0"&+";"K_,,2#''///((6$(GGGrd.r+genitemsz Literal[True]cdSrrrr+rWs rbrzSession.perform_collectV  rdcdSrrrYs rbrzSession.perform_collect\rZrdc | |jj}|d|||jjxjdz c_g|_g|_g|_|jj}|j} g}|D]f}t|jj j ||jj j \}}|j||f||gt||_t#|} |j| |jjxjdzc_|jrRg} |jD]?\}} | r | d|d|d| d '| d |@t)| |s| j}n>| jr7| jD]/} |j|| 0|jj|||j| || n#|| wxYwt;||_|S) aPerform the collection phase for this session. This is called by the default :hook:`pytest_collection` hook implementation; see the documentation of this hook for more details. For testing purposes, it may also be called directly on a fresh ``Session``. This function normally recursively expands any collectors collected from the session to their items, and only items are returned. For testing purposes, this may be suppressed by passing ``genitems=False``, in which case the return value contains these collectors unexpanded, and ``session.items`` is empty. Nrr8 as_pypathr1z not found: z (no name z in any of )zfound no collectors for )rwrrrrv)rrr+rrindent _notfound_initial_partsrrresolve_collection_argumentr*rMrpyargsr=rrr$rIpytest_collectreportrresultpassedrrWr check_pendingrpytest_collection_finishrr) rr+rWrr initialpathsargrpartsreperrors collectorsnodes rbrzSession.perform_collectbs <;#D $dD111 !#FH<>') {>Bj% 8')L , , ;K15"k07!!!  #**FE?;;;##F++++!*>>> K % 3 3 5 5 5  . .T[ /     ) )$ ) 7 7 7 7D ) )$ ) 7 7 7 7!%jj s )FHH7c#B Kddlm}i}i}i}i}|jD]\}}|d||f|jjxjdz c_|jdds|jj}|g|j RD]} | |sn| rn| dz } | rU| |vrQ| | d} | r8t| d|r | d|| <| dg|| dj<| r|rJd ||ft!} t#||jD]} | st'| j}|j}|| vr_| ||dz } | r1| | D]}|Vt||r|||<||vr| |D]0}t/||jf}||vr ||V'|||<|V1n| sJ||vr ||} n9||j|}| |d} | r| ||<g}| |fg}|r|d | ||jjxjdz c_|\}}|D] }|s||t|t6js6t/||jf}||vr ||}nt=|}|||<|jr~g}|j D]R}|j!|dks*|j!"d d|dkr||S|r|||ddf|j#$| |d tK|d|jjxjdzc_||sDd&tO|g|R}|j(|| fx|j!dkr`t|d|rJ tStU|d+Vn#tX$rYnwxYw|Ed{V|jjxjdzc_dS)Nr)Packagezprocessing argumentr8doctestmodulesFz __init__.py)rKz invalid arg matchnodes[r_zmatchnodes finished -> r::)-_pytest.pythonrsrcrrrarrrrri_is_in_confcutdirrrNrVrrJsetr!rJrrrSrPr2rpopr=r Collectorrr$rhrgrsplitrIrfrjoinr]rbnextiterrH StopIteration)rrs node_cache1 node_cache2matchnodes_cache pkg_rootsargpathnamesrrpkginitcol seen_dirsrErJdirpathrkey2 collect_rootmatchingworkru matchnamesrqkeyrn submatchnodesr report_args rbrHzSession.collectsA******>@ QS TV*, "1B (B (NGU JJ,w.> ? ? ? JO " "a ' " " ;(()95AA D[.&999 D DF//88}}D"(="8"??,,D 1K1K"&"3"3G%"3"P"PC"D#-c!fg#>#>!?8;AIf$5>++;%)%6%6w%?%?;;&'#-a#9#9!;9:Ig$6)++ !..t44$$ $Q0;.."-d"3333301K-"#GGGG $)$8(((((k))%g.CC#,==#F#FL&33G%3PPC3/2 G,5\N$0JJ|S%888JO**a/**-1XXZZ*J *HH)%$OOD111$)$@@%$#Dzz4;7"222"23"7CC"24"8"8C47,S1:H,.M%(Z<<%&Fjm$;$;'(v||C'8'8';z!}'L'L$1$8$8$;$;$;,M $ ]JqrrN,K L L L !J;;3;GGGGJJ8#h--QQQJO**a/**I$0L !%CLL+A5+A+A!B!BJN)):s*;<<<<=00Z W5U5U0"4 (;(;(=(=#>#>??????(  ######## JO " "a ' " " "EB (B (s26S)) S65S6rqc#K|d|t|tjr!|j||VdSt|tjsJt|}|jr%|j D]}| |Ed{V|j |dS)NrW)rr_) rrrItemrIpytest_itemcollectedr|r$rhrgrWrf)rrqrnsubnodes rbrWzSession.genitems;s :t$$$ dEJ ' ' 8 J + + + 6 6 6JJJJJdEO44 4 44"4((Cz 6"z66G#}}W5555555555 J + +3 + 7 7 7 7 7rd)r(N)rr8)T)..)NT)+rrrrrr%rrrr\rrr classmethodr|r]r(propertyrrr-rr0r#r"r7rfrmr;rDrJr rr|rVrr rrrrHrW __classcell__)r!s@rbrtrtsK F####c8m$$$$AvA$AAAAAA(I[ #    14111X1141C1111Xt4444 XtTJ 56T TTTT4+uS*<%<=+$++++ ,!326HHH*.H %/ "HHHH0OR  Xc]+ =L %*    X DG  Xc]+ =A % EO34 5   X FJEEXc]+E>BE % EO34 5EEEENP(% EO(C"DEP(P(P(P(d 8%*eo56 8 %*  8 8 8 8 8 8 8 8rd module_namec tj|}n#ttt f$r|cYSwxYw||j |jdkr|S|jr$tj |jS|jS)zTSearch sys.path for the given a dotted module name, and return its file system path.N namespace) rSutil find_specAttributeError ImportError ValueErrororiginsubmodule_search_locationsrrJdirname)rspecs rb search_pypathrKs~'' 44 K 4 |t{*dk[.H.H (wt{+++{s ">>Fr]invocation_pathrlr^ct|d\}}}|d^}}|r|d|||d<|rt|}||z }t |}|s)|rdnd} t | ||r=|r)|rdnd} t | |||fS) a`Parse path arguments optionally containing selection parts and return (fspath, names). Command-line arguments can point to files and/or directories, and optionally contain parts for specific tests selection, for example: "pkg/tests/test_foo.py::TestClass::test_foo" This function ensures the path exists, and returns a tuple: (Path("/full/path/to/pkg/tests/test_foo.py"), ["TestClass", "test_foo"]) When as_pypath is True, expects that the command-line argument actually contains module paths instead of file-system paths: "pkg.tests.test_foo::TestClass::test_foo" In which case we search sys.path for a matching module, and then return the *path* to the found module. If the path doesn't exist, raise UsageError. If the path is a directory and selection parts are present, raise UsageError. rvrwz9module or package not found: {arg} (missing __init__.py?)z"file or directory not found: {arg})rlz9package argument cannot contain :: selection parts: {arg}z;directory argument cannot contain :: selection parts: {arg}) r] partitionr}rrrPrrOr) rrlr^rfsquacketreststrpathrmrrqs rbrdrd\s(2s88--c22D(Djj&&OGe 3Ry2(2D22b )(( w &F & ! !F ==??. 6 G G5 ,,--- .. O G GN ,,--- 5=rd)rwrtr(N)Pr rk dataclassesrr^rSrrpathlibrtypingrrrrrr r r r r rr _pytest._coderr_pytest.compatrr_pytest.configrrrrrr_pytest.config.argparsingr_pytest.fixturesr_pytest.outcomesr_pytest.pathlibrrr r!_pytest.reportsr"r#_pytest.runnerr$r%typing_extensionsr&rcr]r`r\rrrrrmrrrrrrrrrr dataclassr  FSCollectorrtrrdrrdrbrsNN   ######!!!!!!((((((############......%%%%%%,,,,,,++++++!!!!!!((((((''''''&&&&&&!!!!!!))))))&&&&&&++++++%%%%%%*))))))sVssssslCC28 8"FI#6sH}AU8V#VW8 3=8888v''5h+?'''' & 9 %X :N1O     d(F4FDFFFF( 4  HTN    Fej)96d$# -----Y--- dCix8x8x8x8x8ex8x8x8v ss$;@//// #/37/ 4c?//////rd