j7iY3 ddlmZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlZddlZddlZddlZddlmZddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#Z#ddl$Z$ddl$m%Z%ddl&m'Z'ddl&m(Z(ddl)m*Z*ddl)m+Z+ddl,m-Z-ddl.m/Z/ddl.m0Z0dd l.m1Z1dd!l.m2Z2dd"l.m3Z3dd#l.m4Z4dd$l.m5Z5dd%l.m6Z6dd&l.m7Z7dd'l.m8Z8dd(l9m:Z:dd)l9m;Z;dd*l9mZ>dd,l?m@Z@dd-l?mAZAdd.l?mBZBdd/lCmDZDdd0lEmFZFdd1lEmGZGdd2lHmIZIdd3lJmKZKdd4lJmLZLdd5lJmMZMdd6lNmOZOdd7lNmPZPdd8lQmRZRdd9lQmSZSdd:lQmTZTdd;lUmVZVddlYmZZZe!rdd?l[m\Z\dd@l[m]Z]ddAl[m^Z^e"dBdCDZ_e"dEedFe`fGZaedFe_fedFe e_fzZbece_e`dfecde`ecedejdzffzZfddIZg ddJZhddKZiddLZjejdCMGdNdOZle"dPZmenemdfZoddQZpddRZq ddSZrejdCMGdTdUZsGdVdWejZueGdXdYeuZveGdZd[euZweGd\d]exZyGd^d_e+Zz dd`Z{ddaZ| ddbZ}Gdcddee_Z~Gdedfe~euZ ddgZ ddhZeejdCMGdidjZGdkdlZe dFdFdFdFdFdm ddnZe ddFdFdFdFddm ddoZ ddpddqdddm ddrZ ddpddqdddmdsZedHtdduZddvZddwZddxZddyZGdzd{Zdd|Zee$jjZdd}Zdd~ZddZddZdddZy)) annotationsN) defaultdict)deque) OrderedDict)Callable) Generator)Iterable)Iterator)Mapping)MutableMapping)Sequence)Set)Path)Any)cast)Final)final)Generic)NoReturn)overload) TYPE_CHECKING)TypeVar)nodes) getfslineno)Source)FormattedExcinfo) TerminalRepr)TerminalWriter) assert_never) get_real_func)getfuncargnames) getimfunc) getlocation)NOTSET) NotSetType) safe_getattr) safe_isclass) signature) _PluggyPlugin)Config)ExitCode)Parsercheck_ispytest)MARKED_FIXTURE) YIELD_FIXTURE)Session)Mark) ParameterSet) MarkDecorator)fail)skip) TEST_OUTCOME) absolutepath) bestrelpath) _ScopeName) HIGH_SCOPES)Scope)PytestRemovedIn9Warning) PytestWarning) )BaseExceptionGroup) CallSpec2)Function)Metafunc FixtureValueT) covariantFixtureFunction.)boundsessionc$t||_yN)FixtureManager_fixturemanager)rIs Y/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/_pytest/fixtures.pypytest_sessionstartrOms,W5Gcddlm}|jD],}t||s|j|j k(s*|cS|j S)Nr)Package)_pytest.pythonrR iter_parents isinstancenodeidbaseidrI)node fixturedefrRparents rNget_scope_packager[qsK'##% fg &6==Jz(reorder_items_atscope..s$1F?$s rzpypy_version_infoF)last)r<rClensetrpopleftrrgetpopitemreversed appendleftr;hasattrsys move_to_endcopyclearupdater next_loweradd)rrrrcrr items_deque items_doneno_argkey_itemsslicing_argkeyrr_imatching_items other_scopeother_scoped_items_by_argkeyr argkey_dictbkpreordered_no_argkey_itemsrs @rNrrs #e*q. ,U3,U3"uF,K)+J 24&&(Dz!T_%<mm$155dB?$G(,%$+OO$5! 6nE"eA""".18A**1-'28 7F{7S4&5k&B&F&Fq"&M 8F*Fv*NK#*30C#D15 A + 7 7 7 F '2&6&6&8 + 1 1 315 A + 2 23 7 888$EF (=/5CSCSCU) %   7 8  % JJ~ &Y Z ;"s 8 GGcFeZdZUdZdZded<ded<ded<ded <d d Zy ) FuncFixtureInfoaFixture-related information for a fixture-requesting item (e.g. test function). This is used to examine the fixtures which an item requests statically (known during collection). This includes autouse fixtures, fixtures requested by the `usefixtures` marker, fixtures requested in the function parameters, and the transitive closure of these. An item may also request fixtures dynamically (using `request.getfixturevalue`); these are not reflected here. )argnames initialnamesname2fixturedefs names_closuretuple[str, ...]rr list[str]r$dict[str, Sequence[FixtureDef[Any]]]rct}t|j}|ro|j}||vrX||jvrJ|j |||j vr+|j |j |dj|rot||jj|jddy)aRecompute names_closure from initialnames and name2fixturedefs. Can only reduce names_closure, which means that the new closure will always be a subset of the old one. The order is preserved. This method is needed because direct parametrization may shadow some of the fixtures that were included in the originally built dependency tree. In this way the dependency tree can get pruned, and the closure of argnames may get reduced. )keyN) rrpoprrrrrsortedindex)selfclosure working_setros rNprune_dependency_treez%FuncFixtureInfo.prune_dependency_treeNs E$++, !oo'G g%'T5G5G*G G$d333&&t'<'Underlying collection node (depends on current request scope).rrs rNrXzFixtureRequest.node "##rPc.|jjS)z6The pytest config object associated with this request.)rconfigrs rNrzFixtureRequest.configs&&&rPc~|jdk7rtd|jd|jjS)z=Test function object if the request has a per-function scope.functionzfunction not available in -scoped context)rcr~rrirs rNrzFixtureRequest.functionsA :: # ,TZZLH ###rPc|jdvrtd|jd|jjtj j }|r |jSy)z:Class (can be None) where the test function was collected.)classrzcls not available in rN)rcr~rr]rdr`r_ri)rclscols rNrzFixtureRequest.clss\ ::2 2 #8 O!TU U!!++GNN,@,@A ::  rPcP|jdk7ryt|jddS)z)>?wwrPc||jdvrtd|jd|jjS)z+Path where the test function was collected.)rrrpackagezpath not available in r)rcr~rrrs rNrzFixtureRequest.paths< ::G G #9$**_!UV V$$$rPc2|j}|jS)z4Keywords/markers dictionary for the underlying node.)rXkeywords)rrXs rNrzFixtureRequest.keywordss 99}}rPc.|jjS)zPytest session object.)rrIrs rNrIzFixtureRequest.sessions'''rPct)zAdd finalizer/teardown function to be called without arguments after the last test within the requesting test context finished execution.rr finalizers rN addfinalizerzFixtureRequest.addfinalizerrrPc:|jj|y)a Apply a marker to a single test function invocation. This method is useful if you don't want to have a keyword/marker on all function invocations. :param marker: An object created by a call to ``pytest.mark.NAME(...)``. N)rX add_marker)rmarkers rN applymarkerzFixtureRequest.applymarkers V$rPctd||)zqRaise a FixtureLookupError exception. :param msg: An optional custom error message. N)FixtureLookupError)rmsgs rN raiseerrorzFixtureRequest.raiseerrors !tS11rPcp|j|}|j Jd|d|jdS)aDynamically run a named fixture function. Declaring fixtures via function argument is recommended where possible. But if you can only decide whether to use another fixture at test setup time, you may use this function to retrieve it inside a fixture or test function body. This method can be used during the test setup phase or the test run phase, but during the test teardown phase a fixture's value may not be available. :param argname: The fixture name. :raises pytest.FixtureLookupError: If the given fixture could not be found. zThe fixture value for "zQ" is not available. This can happen when the fixture has already been torn down.r)_get_active_fixturedef cached_result)rrorYs rNgetfixturevaluezFixtureRequest.getfixturevaluesS,009 ''3 %gY/K K 3''**rPc#tK|}t|tr"||j}t|tr!yyw)zjYield all SubRequests in the chain, from self up. Note: does *not* yield the TopRequest. N)rU SubRequest_parent_request)rcurrents rN _iter_chainzFixtureRequest._iter_chain"s3 *-M--G*-s388c|dk(r t|S|jj|}||j||j|S|j j|d}|7|j j||j}|||j |<| t|||s t||d}|jD]}|j|k(s|dz}| t|kDr t||||} |jj}|<||jvr.|j|}|j |}|j"|} n%t$}d}|j} |j'||j||jt)|| |||d} |j+| ||j|<|S#t$rd}YwxYw)NrequestrrTrr)RequestFixtureDefrrrrrrMgetfixturedefsrrrrrr}r~paramsrrr$_check_fixturedef_without_paramrexecute) rrorY fixturedefsrrr}paramrqrc subrequests rNrz%FixtureRequest._get_active_fixturedef,s i $T* *''++G4  !   j**;*; < ++//>  ..==gtGWGWXK&1<%%g.  $Wd3 3$Wd3 3'') G""g-   6C $ $$Wd3 3 '  ''00H  Gx$>OOG,E"**73K''0EEK%%E  0 0 < *j&7&78 % Z4 :.&07#5 H s G G! G!c |j}|jdu}t|dd}|r@|r>|jd|jdt |j }t|d|rtjd}tj|d}t|j}|j} t|j|j j"} t'|j(|j j"} d |jd |j*d | d | d | }t|dyy#t$$rt|} YtwxYw)zVCheck that this request is allowed to execute this fixturedef without a param.N nofuncargsFzG does not support fixtures, maybe unittest.TestCase subclass? Node id: z Function type: pytracer?rz=The requested fixture has no parameter defined for test: z Requested fixture 'z' defined in: z Requested here: :)rr rnamerVtyperur5inspectstack getframeinfor8filenamelinenorn relative_torrootpath ValueErrorr#funcro) rrYfuncitem has_paramsfixtures_not_supportedrframe frameinfo source_path source_linenosource_path_strlocations rNr!z.FixtureRequest._check_fixturedef_without_paramxsg##&&d2 !(<!G 0==/"$OO,-""&x."9"9!:<  e $ MMOA&E,,U1X6I&y'9'9:K%,,M 3"%k&=&=hoo>V>V&W"X#:??HOO4L4LMH'(&&0&8&8%9*$"#1]O 5  e $%  3"%k"2 3s=.E E E c~|jDcgc]}|j}}|j|Scc}wrK)r _fixturedefreverse)rrvaluess rN_get_fixturestackz FixtureRequest._get_fixturestacks9595E5E5GH''%%HH Is:N) rrCr str | Nonerrrzdict[str, FixtureDef[Any]]rboolrr)rrLrr<rr:rFixtureDef[object]rr<rr)rr)rr*)rr)rzMutableMapping[str, Any])rr1rzCallable[[], object]rr)r zstr | MarkDecoratorrr)rrDrr)rornrr)rzIterator[SubRequest])rornrrI)rYrIrr)rzlist[FixtureDef[Any]])rurvrwrxrpropertyrMabcabstractmethodrrcrrrXrrrrrrrrIrr rrrrr!rCrzrPrNrrjs  >  1  >88$$!! $0$$  $$ $$''$$;; %%  (( $$ %2+:.JX%BrPrcxeZdZdZddd fdZed dZ d dZedZddZ dd Z dd Z xZ S) TopRequestz7The type of the ``request`` fixture in a test function.Frcrt|d||jjj i|y)N)rrrrr)superr _fixtureinforr)rrr __class__s rNrzTopRequest.__init__s9 !&33DDIIK  rPc"tjSrK)r<rCrs rNrzTopRequest._scopes ~~rPcyrKrzrs rNrzTopRequest._check_scopes rPc|jSrK)rrs rNrXzTopRequest.nodesrPc"d|jdS)Nz)rXrs rN__repr__zTopRequest.__repr__s%dii]!44rPc|j}|jD]/}||jvs|j||j|<1yrK)rrfuncargsr)rrros rN _fillfixtureszTopRequest._fillfixturessI(( GGdmm+)-)=)=g)F g& GrPc:|jj|yrK)rXrrs rNrzTopRequest.addfinalizers y)rP)rrCrrErrrFrHrrnrrJ) rurvrwrxrrKrrrXrYr\r __classcell__rSs@rNrOrOsgABG  0       5G *rPrOceZdZdZdd d fdZd dZed dZedZ ddZ dd Z dd Z xZ S)rzjThe type of the ``request`` fixture in a fixture function requested (transitively) by a test function.Frct||j|j|j|j |||_||_||_|tur||_ ||_ y)N)rrrrr) rQrrrorrr _scope_fieldr@r$r$rq)rrrcr$rqrYrrSs rNrzSubRequest.__init__so **"** ..#44  7>#(6@  DJ"-rPc<d|jd|jdS)Nz .s$&,,Z8&sz'ScopeMismatch: You tried to access the z scoped fixture z with a z2 scoped request object. Requesting fixture stack: z Requested fixture: Fr()rrojoinrCrjr5r)rrrro fixture_stackrequested_fixtures` rNrzSubRequest._check_scopes ;; (*22G II&"&"8"8":&M!% < <=Q R  9/:O:O9PQ")8DKK,=,=+>?..;_=''8&9;   )rPc|j}t|\}}t|tr*t |j j j|}t|}|d|dzd|j|S)Nr*rz: def ) r5rrUrr9rrIrr(ru)rrYfactoryrr1sigs rNrjz"SubRequest._format_fixturedef_linesq//"7+ f dD !t//77<z/FixtureLookupError.formatrepr..0s 166rPz6formatrepr assumptions broken, rewrite it to handle itrzfile z, line rz defz+file %s, line %s: source code not availablez) recursive dependency involving fixture 'z ' detectedz fixture 'z ' not foundz available fixtures: {}z, z6 use 'pytest --fixtures [testpath]' for help on them.) appendrrrirmaprtrrr-getsourcelinesr enumeraterstriplstrip startswithOSError IndexError TypeErrorrMrrZrrr_matchfactoriesrroformatrkrFixtureLookupErrorRepr)rtblinesaddliner.rrfspathr1linesrrline error_msgfm availablerZr+r#faclists rN formatreprzFixtureLookupError.formatrepr,sV..))--. S)4+<+<=>hhxx4#4#4 D 4 ?#2JE H(2NFF "11-2IJq %xwvzl;<(/GAt;;=DD4K({{}//6   ;--BI\\--44F% %%%'%8%8%>%>%@ (!kr11+vFGMM$' (||y(? ~ZX"$,,{; .55diiy@Q6RS SC L LC%ffgsDLLQQ;Z3 :I  VVaZ$889 :s!H//&IIrK)rorDrrrrDrr)rr)rurvrwrxrrrzrPrNrr s7DOS!,:AK 4RrPrc4eZdZ ddZddZy)rcJ||_||_||_||_||_yrK)r errorstringr0 firstlinenoro)rr0rrrros rNrzFixtureLookupErrorRepr.__init__ds) &  & rPc(|jD]!}|j|j#|jj d}|ru|jt j d|djd|ddD]6}|jt jd|jd8|j|jtj|jd|jdzy)Nrhz rTredrr*) rrr~rsplitr fail_markerstrip flow_markerosrr0r)rtwtblinerrs rN toterminalz!FixtureLookupErrorRepr.toterminalrsll %F GGFMMO $ %  &&t,  GG#//0a8H7IJ  ab  '334GDJJL>J    299T]]+,Ad.>.>.B-CDErPN) r0zstr | os.PathLike[str]rrpr Sequence[str]rrnrorDrr)rrrr)rurvrwrrrzrPrNrrcsG (         FrPrctj|rbttdtt f|}|di|} t |}tjt||}|j||Sttdt f|}|di|}|S#t$rt|jddwxYw)N.z did not yield a valuerz)r-isgeneratorfunctionrrrrEnext StopIterationr4r functoolspartial_teardown_yield_fixturer) fixturefuncrkwargs generatorfixture_resultrs rNcall_fixture_funcrs"";/8C<)@$@A;O )&)  W!)_N%%&={IV Y' 8C$56 D $.v.  W 3 344JKLRV V Ws B#B>c  t|t|\}}tdt|j d|d|dzdy#t $rYywxYw)zExecute the teardown of a fixture function by advancing the iterator after the yield and ensure the iteration ends (if not it means there is more than one yield in the function).z-fixture function has more than one 'yield': rhr*rFr(N)rrr5rindentr)ritfsr1s rNrrsl   R!- F =k"))+,Bd!FQJ< !     s A AAc |||}t|tst d|d|d|d |S#t$r}td|d|d|d}~wwxYw) N) fixture_namerzError evaluating z while defining fixture 'zC'. Expected a function with the signature (*, fixture_name, config)z Expected z+ to return a 'str' while defining fixture 'z', but it returned: Fr() ExceptionrrUrnr5)scope_callablerrres rN_eval_scope_callablers  \&I fc " ''RS_R``uj  M //HWO O  s 4 AAAceZdZdZ d ddd d dZeddZddZddZdd Z dd Z dd Z y) FixtureDefzA container for a fixture definition. Note: At this time, only explicitly documented fields and methods are considered public stable API. NF)r_autousect||xsd|_|du|_||_||_|t j }nt|r t|||}t|tr&t j|d|jd|}||_ ||_||_t!|||_d|_g|_| |_y)Nz Fixture '')descrwherer+)r.rW has_locationr5ror<rCcallablerrUrn from_userrurr idsr!rr _finalizersr) rrrWror5rcr rrrs rNrzFixtureDef.__init__s y!$\r $*#5 % =NNE e_(@E eS !OOyq9E# # .t'B IM>@! rPc.|jjSrrrs rNrczFixtureDef.scoperrPc:|jj|yrK)rrzrs rNrzFixtureDef.addfinalizer s  *rPcg}|jr/|jj} ||jr/|j}|j j ||d|_|jjt|dk(r|dt|dkDr$d|jd|}t||dddy#t$r}|j|Yd}~d}~wwxYw)NrYrrrz#errors while tearing down fixture "z" of r) rr BaseExceptionrzrXihookpytest_fixture_post_finalizerrrrrorA)rr exceptionsfinrrXrs rNfinishzFixtureDef.finish s*, ""&&(C % || 00D'0R"  z?a Q-  _q 7 ~U4&QC$S*TrT*:; ;!! %!!!$$ %sC C2C--C2cg}|jD]$}|j|}|j|&|j|j |}|jd} t ||k(}|rA|jd#|jd\}} |j| |jdS|j||jJtj|j|} |D]} | j| |jj} | j||} |jj| | S#t tf$r||u}YwxYw#|jj| wxYw)z=Return the value of this fixture, executing it if not cached.rrrr)rrrzr cache_keyrEr4 RuntimeErrorwith_tracebackrrrrrXrpytest_fixture_setup)rr*requested_fixtures_that_should_finalize_usrorYrequest_cache_keyr cache_hitexcexc_tbrparent_fixturerrs rNr"zFixtureDef.execute"s682}} JG 77@J 7 = =j I J    ) $w 7 **1-I ;!!2i!?@ %%a(4"&"4"4Q"7KC,,V44--a00 KK %%- -- %%dkk7C H 3N  ' ' 2 3 "" 1$)#=#=$>$F LL % %i 0 C - ;-:  ;> LL % %i 0s#E#E,E)(E),F ct|ddS)Nr$)r)rrs rNrzFixtureDef.cache_key_sw..rPcVd|jd|jd|jdS)Nz.qsrPT)rrWror5rcr rr)rQrrr<rCr)rrrSs `rNrzRequestFixtureDef.__init__lsE >> ..  &sD1rPcyrKrzrs rNrzRequestFixtureDef.addfinalizerxs rP)rrrrrJ)rurvrwrxrrr_r`s@rNrrfs 2 rPrc|j}|j}|ct|dr"t||jj s|St |j}||jk7r|j|}|S)zKGet the actual callable that can be called to obtain the fixture value.__self__)r5rrrUrrSr"__get__)rYrrrs rNresolve_fixture_functionr|s} //KH ; +J   * *5   0 *// )%--h7K rPc Pi}|jD]}|j|||<t||}|j|}t j |st j |rV|jrdnd}tjt|jjd|j|dd t|||}||df|_|S#t$r=}t!|t"j$rd|_d|||j(ff|_d}~wwxYw) zExecution of fixture setup.z with autouse=Truerz requested an async fixture z, with no plugin or hook that handled it. This is usually an error, as pytest does not natively support it. This will turn into an error in pytest 9. See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixturer stacklevelTN)rrrrr-isasyncgenfunctioniscoroutinefunctionrwarningswarnr=rXr+rrr7rUr6r_use_item_location __traceback__r) rYrrror my_cache_keyauto_strrrs rNrrs6F&&;!11':w;+:w?K''0L!!+.'2M2M3,6+>+>'B #<<$$''C&&)(4pp   ";@!' d;J M  a ($(A $(,AOO8L#M   s C D%(8D  D%cjeZdZUded<ded<dZded<dZd ed <dZd ed <dZd ed<ddZddZ y)FixtureFunctionMarker0_ScopeName | Callable[[str, Config], _ScopeName]rcztuple[object, ...] | Noner FrEautouseNrrrDr+zdataclasses.InitVar[bool]rct|yrKr-)rrs rN __post_init__z#FixtureFunctionMarker.__post_init__s y!rPcttj|r tdt|trtd|j t |drtjtdt ||d}|jxs |j }|dk(rt|}td |d |S) Nz2class fixtures not supported (maybe in the future)zE@pytest.fixture is being applied more than once to the same function pytestmarkrrT)rfixture_function_markerrrz?'request' is a reserved word for fixtures, use another name: Fr() r-isclassr4rUrgrurrrr/r+r#r5)rrfixture_definitionr+r>s rN__call__zFixtureFunctionMarker.__call__s ??8 $QR R h 9 :WX`XiXiWlm  8\ * MM.Q 76tt yy-H-- 9 "8,H RS[R\]  "!rP)rrErr)rrGrrg) rurvrwryrrr+rrrrzrPrNrrsD <; %%GTMQC JQD*+0I(0""rPrcNeZdZddd d dZd dZd dZd dZd dZy)rgNF)rrc"t||jxs |j|_|j|_||_|.t t dt f|j||_n||_tj||y)N.) r.r+rurhrrrr_fixture_functionrupdate_wrapper)rrrrrs rNrz"FixtureFunctionDefinition.__init__s y!+00EH4E4E   (?%  %)c"H$4$4X$>&D "&.D "  x0rPc"d|jdS)Nzrrs rNrYz"FixtureFunctionDefinition.__repr__s!$"8"8!9<d|jd}t|dy)Nz Fixture "aE" called directly. Fixtures are not meant to be called directly, but are created automatically when test functions request them as parameters. See https://docs.pytest.org/en/stable/explanation/fixtures.html for more information about fixtures, and https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directlyFr()r+r5)rargskwdsmessages rNrz"FixtureFunctionDefinition.__call__ s* {#\ \  We$rPc|jSrKrrs rN_get_wrapped_functionz/FixtureFunctionDefinition._get_wrapped_functions%%%rP) rCallable[..., Any]rrrz object | NonerrErrr^rK)r rr rrr)rr)rurvrwrrYrrr rzrPrNrgrgsU #' 1%1"7 1  1  1 1,= %&rPrgrcr rrr+cyrKrzfixture_functionrcr rrr+s rNfixturers!$rPcyrKrzrs rNrr%s rPrFct|| t|nd||dnt|r|n t||d}|r||S|S)aDecorator to mark a fixture factory function. This decorator can be used, with or without parameters, to define a fixture function. The name of the fixture function can later be referenced to cause its invocation ahead of running tests: test modules or classes can use the ``pytest.mark.usefixtures(fixturename)`` marker. Test functions can directly use fixture names as input arguments in which case the fixture instance returned from the fixture function will be injected. Fixtures can provide their values to test functions using ``return`` or ``yield`` statements. When using ``yield`` the code block after the ``yield`` statement is executed as teardown code regardless of the test outcome, and must yield exactly once. :param scope: The scope for which this fixture is shared; one of ``"function"`` (default), ``"class"``, ``"module"``, ``"package"`` or ``"session"``. This parameter may also be a callable which receives ``(fixture_name, config)`` as parameters, and must return a ``str`` with one of the values mentioned above. See :ref:`dynamic scope` in the docs for more information. :param params: An optional list of parameters which will cause multiple invocations of the fixture function and all of the tests using it. The current parameter is available in ``request.param``. :param autouse: If True, the fixture func is activated for all tests that can see it. If False (the default), an explicit reference is needed to activate the fixture. :param ids: Sequence of ids each corresponding to the params so that they are part of the test id. If no ids are provided they will be generated automatically from the params. :param name: The name of the fixture. This defaults to the name of the decorated function. If a fixture is used in the same module in which it is defined, the function name of the fixture will be shadowed by the function arg that requests the fixture; one way to resolve this is to name the decorated function ``fixture_`` and then use ``@pytest.fixture(name='')``. NT)rcr rrr+r)rtupler)rrcr rrr+fixture_markers rNrr1sUv+ & 2uV}KDHSMSuSz  N.// rPc ^tjtdt|g||||||dS)z(Return a) decorator to mark a yield-fixture factory function. .. deprecated:: 3.0 Use :py:func:`pytest.fixture` directly instead. rrr)rrr0r)rrcr rrr+r s rN yield_fixturer|s@ MM-A.       rP)rcc|jS)zSession-scoped fixture that returns the session's :class:`pytest.Config` object. Example:: def test_foo(pytestconfig): if pytestconfig.get_verbosity() > 0: ... rrs rN pytestconfigrs >>rPc|jddgd|jd}|jdddd d d |jd ddd d y)N usefixturesr z5List of default fixtures to be used with this project)r,defaulthelpgeneralz --fixturesz --funcargs store_true showfixturesFziShow available fixtures, sorted by plugin appearance (fixtures with leading '_' are only shown with '-v'))actiondestrr z--fixtures-per-testshow_fixtures_per_testzShow fixtures per test)addinigetgroup addoption)parsergroups rNpytest_addoptionr,sv MM  D  OOI &E OO ?  OO % % rPc|jjr t|y|jjr t|yy)Nr)optionr#r&rs rNpytest_cmdline_mainr/s5 }}!!V }}++v& rPct}|jdD]\}|jjddr t j |j i|j\}}|j|^|S)a Return all direct parametrization arguments of a node, so we don't mistake them for fixtures. Check https://github.com/pytest-dev/pytest/issues/5036. These things are done later as well when dealing with parametrization so this could be improved. parametrizerindirectF)r iter_markersrrr3_parse_parametrize_argsr r)rXparametrize_argnamesr  p_argnamesrs rN_get_direct_parametrize_argsr7s|&)U###74}}  U3(@@ & MJ ! ' ' 3 4 rPcLttjd|DS)zDDe-duplicate the sequence of names while keeping the original order.c3.K|] }|D]}|ywrKrz)rseqr+s rNrz$deduplicate_names..sDDtDtDs)rrr)seqss rNdeduplicate_namesr<s DtDD EErPceZdZdZddZ ddZddZddZddZ ddZ ddZ dd Z d d d d d  ddZ e ddZe ddZef ddZ d dZ d!dZy )"rLapytest fixture definitions and information is stored and managed from this class. During collection fm.parsefactories() is called multiple times to parse fixture function definitions into FixtureDef objects and internal data structures. During collection of test functions, metafunc-mechanics instantiate a FuncFixtureInfo object which is cached per node/func-name. This FuncFixtureInfo object is later retrieved by Function nodes which themselves offer a fixturenames attribute. The FuncFixtureInfo object holds information about fixtures and FixtureDefs relevant for a particular function. An initial list of fixtures is assembled like this: - config-defined usefixtures - autouse-marked fixtures along the collection chain up from the function - usefixtures markers at module/class/function level - test function funcargs Subsequently the funcfixtureinfo.fixturenames attribute is computed as the closure of the fixtures needed to setup the initial fixtures, i.e. fixtures needed by fixture functions themselves are appended to the fixturenames list. Upon the test-setup phases all fixturenames are instantiated, retrieved by a lookup of their FuncFixtureInfo. c||_|j|_i|_t|_d|jj di|_|jjj|dy)Nrr funcmanage) rIrrr_holderobjseengetini_nodeid_autousenames pluginmanagerregister)rrIs rNrzFixtureManager.__init__sg %nn JL25%  ""=1B ! $$--dLArPc|&t|ddst||j|}nd}|j|}|j |}t |||}t |}|j|||\} } t||| | S)aCalculate the :class:`FuncFixtureInfo` for an item. If ``func`` is None, or if the item sets an attribute ``nofuncargs = True``, then ``func`` is not examined at all. :param node: The item requesting the fixtures. :param func: The item's function. :param cls: If the function is a method, the method's class. r'F)r+rrz) parentnoder ignore_args) rr!r+_getusefixturesnames_getautousenamesr<r7getfixtureclosurer) rrXr5rrusefixturesnames autousenamesrdirect_parametrize_argsrrs rNgetfixtureinfozFixtureManager.getfixtureinfos$  GD,$F&t$))EHH44T:,,T2 (7GR ">t"D)-)?)?%/*@* &  x}oVVrPc|r|jdrt|} t|jj |j j }|dk(rd}tjtjk7r1|jtjtj}nd}|j||y#t$rd}YywxYw)Nz conftest.pyr.)endswithr8rnrZr2rr3r4rseprSEPreplaceparsefactories)rplugin plugin_name conftestpathrVs rNpytest_plugin_registeredz'FixtureManager.pytest_plugin_registered4s ;// > ( 4L \00<rV)rrX marker_nodemarks rNrHz#FixtureManager._getusefixturesnamesSsj!%!.process_argnamets""7+r122$++G4+%)--g6K"11':F "+6(#''4EvK(($U+J',qyOG $!** %$ %',OG $rPcl |}|djS#t$rtjcYSwxYw)Nr)rKeyErrorr<rC)arg_namer#rs rN sort_by_scopez7FixtureManager.getfixtureclosure..sort_by_scopes? .-h7 #2--- &~~% &s 33T)rrA)rornrr)rirnrr<)rsort) rrFrrGr+rjrrdrerfs `` ` @@@@rNrJz FixtureManager.getfixtureclosure^sd $L1@B +- - -<! "D D ! " . !!mT!B#_44rPc dd|jD]|jj}|s!tfd|jj dDrPt |D]T}|j6|j|jd|j|j|jvsTy)zLGenerate new tests based on parametrized fixtures used by the given metafuncc^tj|ji|j\}}|SrK)r3r4r r)r`r rs rNget_parametrize_mark_argnameszKFixtureManager.pytest_generate_tests..get_parametrize_mark_argnamess("::DIIUUGD!KrPc32K|]}|vywrKrz)rr`rorns rNrz7FixtureManager.pytest_generate_tests..s$8>>sr1NT)r2rcr)r`r2rr) rrrany definitionr3rr r1rcrr)rmetafuncrrYrorns @@rNpytest_generate_testsz$FixtureManager.pytest_generate_testss  ,," G#4488AL$//<<]K '|4  $$0(("))!%(..&NN )*"5"55 )" rPc t||ddyrK)r)rrs rNpytest_collection_modifyitemsz,FixtureManager.pytest_collection_modifyitemss 'arPrNF)rcr rrc t|j||||||d| }|jj|g} |jr| j |n8t | D cgc]} | jr| c} } | j| ||r0|jj|xsdgj |yycc} w)aRegister a fixture :param name: The fixture's name. :param func: The fixture's implementation function. :param nodeid: The visibility of the fixture. The fixture will be available to the node with this nodeid and its children in the collection tree. None means that the fixture is visible to the entire collection tree, e.g. a fixture defined for general use in a plugin. :param scope: The fixture's scope. :param params: The fixture's parametrization params. :param ids: The fixture's IDs. :param autouse: Whether this is an autouse fixture. T) rrWror5rcr rrrrN) rrr setdefaultrrzrinsertrB) rr+r5rVrcr rr fixture_defrfrs rN_register_fixturez FixtureManager._register_fixtures>!;;  ''224<  # # NN; ' >1q~~Q>?A NN1k *   % % 0 02r B I I$ O ?s "C4CctrKr)r node_or_objs rNrUzFixtureManager.parsefactories s "##rPctrKr)rr}rVs rNrUzFixtureManager.parsefactoriesrrPc |tur|}n^t|tjsJt t |j }t|jtsJ|j}||jvryt|s&t|tjs t|}n|}|jj|t|D]}t!||d}t|t"us"|j$}|j&r |j&}n|} t)||} | j-} |j/||| |j0|j2|j4|j6y#t*$r|} Y`wxYw)axCollect fixtures from a collection node or object. Found fixtures are parsed into `FixtureDef`s and saved. If `node_or_object` is a collection node (with an underlying Python object), the node's object is traversed and the node's nodeid is used to determine the fixtures' visibility. `nodeid` must not be specified in this case. If `node_or_object` is an object (e.g. a plugin), the object is traversed and the given `nodeid` is used to determine the fixtures' visibility. `nodeid` must be specified in this case; None and "" mean total visibility. N)r+rVr5rcr rr)r$rUrNoderrrirVrnr@r'types ModuleTyper,rdirr&rgrhr+rr~r r{rcr rr) rr}rV holderobj holderobj_tpr+obj_ubr rrir5s rNrUzFixtureManager.parsefactoriessa&  #Ik5::6 66V[__5Ik00#6 66 ''F ++ + I&z)UEUEU/V#' ?L$L  * N D",d;FF|8888;;#);;L#'L!!)T2C 002&&%! ,,!== "NN') &! C!s E;; F F cv |j|}t|j||S#t$rYywxYw)aGet FixtureDefs for a fixture name which are applicable to a given node. Returns None if there are no fixtures at all defined with the given name. (This is different from the case in which there are fixtures with the given name, but none applicable to the node. In this case, an empty result is returned). :param argname: Name of the fixture to search for. :param node: The requesting Node. N)rrhrr)rrorXr#s rNrzFixtureManager.getfixturedefsZsE //8KT))+t<==  s , 88c#K|jDchc]}|j}}|D]}|j|vs|ycc}wwrK)rTrVrW)rr#rXn parentnodeidsrYs rNrzFixtureManager._matchfactoriesnsQ,0+<+<+>?a? ?% !J  M1   !@sA AA  A rIr1rr)rX nodes.Itemr5zCallable[..., object] | Nonerrsrr)rVr)rWrnrr)rX nodes.Noder Iterator[str])rXrrr)rFrrrrGzAbstractSet[str]rz6tuple[list[str], dict[str, Sequence[FixtureDef[Any]]]])rrrDrr)rlist[nodes.Item]rr)r+rnr5z_FixtureFunc[object]rVrDrcz8Scope | _ScopeName | Callable[[str, Config], _ScopeName]r rrrrrErr)r}rrr)r}rrVrDrr)r}znodes.Node | objectrVzstr | NotSetType | Nonerr)rornrXrrz Sequence[FixtureDef[Any]] | None)r#zIterable[FixtureDef[Any]]rXrrzIterator[FixtureDef[Any]])rurvrwrxrrNrYrIrHrJrsrur{rrUr$rrrzrPrNrLrLs< B"W"W+"W "W  "WH,0% !@5@5&@5& @5 @ @5D)Z(KU*.QU6P6P# 6P  6P H 6P(6PO6P6P 6Pp$$ $$ $$$  $$+1@(@(@  @D>>",> )>(!4!3//0s AAAc ddl}|j|jj|jj ||j dfd dfd d fd }|jD] }|| y)NrcFt|}tt|SrK)r#r9r)r5rrs rNget_best_relpathz1_show_fixtures_per_test..get_best_relpaths $/>4955rPc|j}dkr|jdryt|j}j |dj d|dj dt j |j}|r-tdkr|jdd dy|yjd d y) NrrTgreen -- yellowrh rmaxsplit no docstring availabler) rorrr5writer-getdocwrite_docstringrr)ryro prettypath fixture_docrrverboses rN write_fixturez._show_fixtures_per_test..write_fixtures%% a.write_items'.t^T'J C""C(D0 HHj((#. /    ))*OO..(I&&    &NNM;D7 GZ F "$$Z0 s4VH=> & a version_infoexceptiongrouprArSrBrCrDrErrG _FixtureFuncrr TracebackType_FixtureCachedResultrOr[rerj dataclassrmr{r OrderedSetrrrrABCrrOr LookupErrorrrrrrrrrrrrgrrrr,r/r7r<rLr&__file__rZrrrr#rrrzrPrNrs" ##$%$$#*$.   % /+&'(*$&!%''$(!#,--, %1!!)('$%9/g1(''~6 +8CK3HI\)*Xc9\;R6R-SS       mU004778  : $6   "  4d#$$ T] "d(^ L<*> !>Q>>  >>Bd#7N7N$7NtrSWWrj &*&*&*RS1S1S1l?R?R?RDF\FD+6D$ $7  .cd&cdL >2 ,(3A0(((3=((Vd#$"$"$$"P-&-&` ?B&)KN$+$ <$ $ $  $ I $ $$ $   ?B&)KN   <  $    I       04H?I&*KOH,H <H $ H  H I H H7HX    4 y  4 &F R!R!j 9 7##$++ 02!j4 6rrP