403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/_pytest/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/_pytest/__pycache__/fixtures.cpython-39.pyc
a

05d��@s ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#Z#ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl'm)Z)ddl*m+Z+ddl,m-Z-dd l,m.Z.dd!l,m/Z/dd"l,m0Z0dd#l,m1Z1dd$l,m2Z2dd%l,m3Z3dd&l,m4Z4dd'l,m5Z5dd(l,m6Z6dd)l,m7Z7dd*l,m8Z8dd+l,m9Z9dd,l:m;Z;dd-l:m<Z<dd.l=m>Z>dd/l?m@Z@dd0l?mAZAdd1lBmCZCdd2lBmDZDdd3lEmFZFdd4lGmHZHdd5lGmIZIdd6lGmJZJdd7lKmLZLdd8lKmMZMdd9lNmOZOdd:lNmPZPdd;lQmRZRe �r2dd<lmSZSdd=lNmTZTdd>lUmVZVdd?lWmXZXdd@lWmYZYe!dA�ZZe!dBedCe[fdD�Z\e"edCeZfedCeeZddfffZ]e"eeZe[dfede[eee^e^efffZ_ej`dEdF�GdGdH�dHeeZ��ZadIddJ�dKdL�ZbdMdN�dOdP�Zce$jdePee"e$jee$jffdQ�dRdS�ZgeReehdTf�Zie$jfdUdVddW�dXdY�Zje[edZd[�d\d]�Zkee[dCfZle$jeePeeld^�d_d`�Zmee$jeee$jeda�dbdc�Zne$jeeePee$jeeeldfffeePeelddffdde�dfdg�Zoee$jedfeePee$jeeeldfffeePeelddffePee$jedfdh�didj�Zpdkedl�dmdn�Zqej`Gdodp�dp��ZrGdqdk�dk�Zse0Gdrds�dses��Zte0Gdtdu�dueu��ZvGdvdw�dwe)�Zwehedx�dydz�Zxd{eseZd|�d}d~�Zydd�d�d��Zzd�ehe<d�d��d�d��Z{e0Gd�d��d�eeZ��Z|e|eZesd{d��d�d��Z}e|eZeteZd��d�d��Z~ee"eee[eegee[ffee"eee[dCfeegee[ffd��d�d��Zeee[eee[dCfd��d�d��Z�e\dZe\d��d�d��Z�e0ej`dEdF�Gd�dZ�dZ���Z�e8dCdCdCdCdCd��e\d�eee[e�ee"eee[eegee[ffeehe\d��d�d���Z�e8d�dCdCdCdCdd��dd�eee[e�ee"eee[eegee[ffeehe�d��d�d���Z�d�d�dd�ddd��ee\d�eee[e�ee"eee[eegee[ffeehe"e�e\fd��d�d��Z�d�d�dd�ddd��d�d��Z�e�d�d��ese<dl�d�d���Z�e>dd��d�d��Z�Gd�dV�dV�Z�dS)��N)�defaultdict)�deque)�suppress)�Path)�
TracebackType)�Any)�Callable)�cast)�Dict)�	Generator)�Generic)�Iterable)�Iterator)�List)�MutableMapping)�NoReturn)�Optional)�Sequence)�Set)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union)�nodes)�getfslineno)�FormattedExcinfo)�TerminalRepr)�TerminalWriter)�_format_args)�_PytestWrapper)�assert_never)�final)�
get_real_func)�get_real_method)�getfuncargnames)�	getimfunc)�getlocation)�is_generator)�NOTSET)�overload)�safe_getattr)�
_PluggyPlugin)�Config)�Parser��check_ispytest)�
YIELD_FIXTURE)�Mark)�ParameterSet)�
MarkDecorator��fail)�skip)�TEST_OUTCOME)�absolutepath)�bestrelpath)�HIGH_SCOPES)�Scope)�StashKey)�Deque)�
_ScopeName)�Session)�	CallSpec2)�Metafunc�FixtureValue�FixtureFunction.)�boundT)�frozenc@seZdZUded<eed<dS)�PseudoFixtureDefz"_FixtureCachedResult[FixtureValue]�
cached_result�_scopeN)�__name__�
__module__�__qualname__�__annotations__r<�rNrN�4/usr/lib/python3.9/site-packages/_pytest/fixtures.pyrGis
rGr@��session�returncCst|�|_dS�N)�FixtureManager�_fixturemanager)rQrNrNrO�pytest_sessionstartosrV�FixtureDef[object])�
fixturedefcCsTddl}|j}|}d�|jd�}|rBt|�|us:||jkrB|j}q |durP|jS|S)Nrz{}/{}z__init__.py)�pytest�Package�format�baseid�type�nodeid�parentrQ)�noderXrY�cls�currentZfixture_package_namerNrNrO�get_scope_packagess
��rc)r`�scoperRcCs�ddl}|tjur|�tj�S|tjur6|�|jj�S|tjurN|�|jj�S|tj	urf|�|jj	�S|tj
ur~|�|jj
�St|�dS)Nr)
�_pytest.pythonr<�Function�	getparentr�Item�Class�python�ModulerZr@�mainr!)r`rd�_pytestrNrNrO�get_scope_node�s




rn�FixtureDef[Any]rBrT)�	collector�metafunc�fixturemanagerrRcCs~|jdjsdSi}i}|jD]~}|j��D]d\}}||jvsBJ�||j|<|�|g�}t|�|j|<|�|�||vr,|j�	|t
j�}	|	||<q,|j��q|j
}
|��D]�\}}||}	d}|	t
jur�t||	�}|dur�|	t
jur�t|tjj�s�J�|}|du�rd}
ni}|j�t|�}
|
du�rB||
v�rB|
|g|
|<q�t|d|t|||ddd�}|g|
|<|
dur�||
|<q�dS)Nr�F�rrr\�argname�funcrd�params�unittest�ids)Z_calls�funcargs�itemsrw�
setdefault�len�indices�append�
_arg2scope�getr<rf�clear�_arg2fixturedefsrnri�
isinstancermrjrkZstash�name2pseudofixturedef_key�
FixtureDef�get_direct_param_fixture_func)rprqrrZ
arg2paramsZ	arg2scope�callspecruZargvalueZarg2params_listrd�arg2fixturedefsZ	valuelistr`Zname2pseudofixturedef�defaultrXrNrNrO�add_funcarg_pseudo_fixture_def�s^	





�
��

r��FixtureFunctionMarker)�objrRcCstttt|dd��S)zJReturn fixturemarker or None if it doesn't exist or raised
    exceptions.�_pytestfixturefunctionN)r	rr�r+)r�rNrNrO�getfixturemarker�s
�r�)�itemrdrRccs�|tjusJ�z
|j}Wnty*Yn�0|}t|j���D]�\}}|j||krVq>|tjurj||f}nZ|tj	ur�|||j
jf}n@|tjur�|||j
f}n(|tj
ur�|j}|||j
|f}nt|�|Vq>dS)zWReturn list of keys for all parametrized arguments which match
    the specified scope.N)r<rfr��AttributeError�sortedr~r{r�r@rZ�pathr_rkrirar!)r�rdr��csru�param_index�keyZitem_clsrNrNrO�get_parametrized_fixture_keys�s(





r��r{rRc
Cs�i}i}tD]`}i}|||<tt�}|||<|D]:}t�t||�d�}|r0|||<|D]}||�|�qVq0qt�|d�}	tt|	||t	j
��SrS)r;rr�dict�fromkeysr�r�list�reorder_items_atscoper<r@)
r{�
argkeys_cache�items_by_argkeyrd�dZitem_dr��keysr�Z
items_dictrNrNrO�
reorder_itemss"�r�zDeque[nodes.Item])r�r�r�rRcCs6tD],}||�|g�D]}|||�|�qqdSrS)r;r��
appendleft)r�r�r�rdr�rNrNrO�fix_cache_order$sr�)r{r�r�rdrRcs|tjust��dkr�St��t��}i}||}||}|�ri}d}	|r�|��}
|
|vsJ|
|vrhqJt��fdd�|�|
g�D�d�}|s�d||
<qJ|�	�\}	}�fdd�||	D�}
t
|
�D]}t|||�|�|�q�q�qJ|�rt
||||���}|D]}
d||
<q���|	�q<|S)N�c3s|]}|�vr|VqdSrSrN)�.0�k)�ignorerNrO�	<genexpr>C�z(reorder_items_atscope.<locals>.<genexpr>csg|]}|�vr|�qSrNrN)r��i)r{rNrO�
<listcomp>Ksz)reorder_items_atscope.<locals>.<listcomp>)r<rfr}�setr�popleftr�r�r��popitem�reversedr�r�r�Z
next_lower�add)r{r�r�rdZitems_dequeZ
items_doneZscoped_items_by_argkeyZscoped_argkeys_cacheZno_argkey_groupZslicing_argkeyr�Zargkeys�_Zmatching_itemsr�rN)r�r{rOr�.sF�

��
r��FixtureRequest��requestrRcCs|jSrS)�param�r�rNrNrOr�\sr�c@s`eZdZUdZeedfed<eedfed<eeed<eee	dfed<dd	�d
d�Z
dS)�FuncFixtureInfo)�argnames�initialnames�
names_closure�name2fixturedefs.r�r�r�ror�N�rRcCsxt�}t|j�}|rZ|��}||vr||jvr|�|�||jvr|�|j|dj�qt||jj	d�|jdd�<dS)a�Recompute 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.
        ���)r�N)
r�r��popr�r�r��updater�r��index)�selfZclosureZworking_setrurNrNrO�prune_dependency_treems


z%FuncFixtureInfo.prune_dependency_tree)rJrKrL�	__slots__r�strrMrr
rr�rNrNrNrOr�`s
r�c@seZdZdZdd�edd�dd�Zedd	�d
d��Zeee	d	�dd
��Z
edd��Ze	dd�dd�Zee
d	�dd��Zedd��Zedd��Zedd��Zedd��Zeed	�dd��Zeee	efd	�d d!��Zed"d	�d#d$��Zegefdd%�d&d'�Zegefdd%�d(d)�Zee	efdd*�d+d,�Ze e	e!d-�d.d/�Z"dd	�d0d1�Z#e	ed�d2d3�Z$e	ed4e%efd�d5d6�Z&edd	�d7d8�Z'd4dd9�d:d;�Z(d4d<dd=�d>d?�Z)e	e*e*dd@�dAdB�Z+ee	d	�dCdD�Z,ee*dfee-j.e-j/fdE�dFdG�Z0e	d	�dHdI�Z1dS)Jr�z�A request for a fixture from a test or fixture function.

    A request object gives access to the requesting test context and has
    an optional ``param`` attribute in case the fixture is parametrized
    indirectly.
    F��	_ispytestN�r�rRcCsLt|�||_d|_tj|_i|_|j}|j�	�|_
i|_|jj
|_
|dSrS)r0�_pyfuncitem�fixturenamer<rfrI�
_fixture_defs�_fixtureinfor��copyr��
_arg2indexrQrU)r�Z
pyfuncitemr�ZfixtureinforNrNrO�__init__�s
	zFixtureRequest.__init__r?r�cCs|jjS�zIScope string, one of "function", "class", "module", "package", "session".�rI�value�r�rNrNrOrd�szFixtureRequest.scopecCs(t|jjj�}|�t|j��|��|S)z-Names of all active fixtures in this request.)r�r�r�r��extendr�r��
difference)r��resultrNrNrO�fixturenames�szFixtureRequest.fixturenamescCs|�|j�S)z>Underlying collection node (depends on current request scope).)�
_getscopeitemrIr�rNrNrOr`�szFixtureRequest.nodero)rurRcCs�|j�|d�}|durH|jjdus&J�|jjj}|j�||�}||j|<|j�|d�d}|dusp|t|�krzt	||��||j|<||S)Nr�)
r�r�r�r_r^rU�getfixturedefsr�r}�FixtureLookupError)r�ru�fixturedefs�parentidr�rNrNrO�_getnextfixturedef�s



z!FixtureRequest._getnextfixturedefcCs|jjS)z6The pytest config object associated with this request.)r��configr�rNrNrOr��szFixtureRequest.configcCs$|jdkrtd|j�d���|jjS)z=Test function object if the request has a per-function scope.�functionzfunction not available in �-scoped context)rdr�r�r�r�rNrNrOr��s

�zFixtureRequest.functioncCs:|jdvrtd|j�d���|j�tjj�}|r6|jSdS)z:Class (can be None) where the test function was collected.)�classr�zcls not available in r�N)rdr�r�rgrmrjrir�)r�ZclscolrNrNrOra�s

zFixtureRequest.clscCs:z
|jjWSty4t|dd�}t|dd�YS0dS)z<Instance (can be None) on which test function was collected.r�N�__self__)r�Z	_testcaser��getattr)r�r�rNrNrO�instance�s

zFixtureRequest.instancecCs.|jdvrtd|j�d���|j�tjj�jS)z;Python module object where the test function was collected.)r�r��modulezmodule not available in r�)rdr�r�rgrmrjrkr�r�rNrNrOr��s
zFixtureRequest.modulecCs$|jdvrtd|j�d���|jjS)z+Path where the test function was collected.)r�r�r��packagezpath not available in r�)rdr�r�r�r�rNrNrOr��s
zFixtureRequest.pathcCs|j}|jS)z4Keywords/markers dictionary for the underlying node.)r`�keywords)r�r`rNrNrOr��szFixtureRequest.keywordsr@cCs|jjS)zPytest session object.)r�rQr�rNrNrOrQszFixtureRequest.session��	finalizerrRcCs|j||jd�dS)��Add finalizer/teardown function to be called without arguments after
        the last test within the requesting test context finished execution.�rdN)�
_addfinalizerrd�r�r�rNrNrO�addfinalizerszFixtureRequest.addfinalizercCs|�|�}|�|�dSrS)r�r�)r�r�rdr`rNrNrOr�s
zFixtureRequest._addfinalizer)�markerrRcCs|j�|�dS)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)r`Z
add_marker)r�r�rNrNrO�applymarkers	zFixtureRequest.applymarker��msgrRcCs|j�d||��dS)zqRaise a FixtureLookupError exception.

        :param msg:
            An optional custom error message.
        N)rUr�)r�r�rNrNrO�
raiseerrorszFixtureRequest.raiseerrorcCs<|j}t|d|j�}|D]}||jvr|�|�|j|<qdS)Nr�)r�r�r�rz�getfixturevalue)r�r�r�rurNrNrO�
_fillfixtures"s

zFixtureRequest._fillfixturescCs.|�|�}|jdus$Jd|�d���|jdS)a�Dynamically 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.
        NzThe fixture value for "zQ" is not available.  This can happen when the fixture has already been torn down.r)�_get_active_fixturedefrH)r�rurXrNrNrOr�)s


�zFixtureRequest.getfixturevaluerWcCs�z|j|WStyjz|�|�}Wn<tyd|dkr^|dgdf}t|tj�YYS�Yn0Yn0|�|�||j|<|S)Nr�r)r��KeyErrorr�r�rGr<rf�_compute_fixture_value)r�rurXrHrNrNrOr�As

z%FixtureRequest._get_active_fixturedefcCs2|}g}t|t�r&|�|j�|j}q|��|SrS)r��
SubRequestr�_fixturedef�_parent_request�reverse)r�rb�valuesrNrNrO�_get_fixturestackTs
z FixtureRequest._get_fixturestack)rXrRc
Cs�|j}|j}|j}z
|j}Wnty2d}Yn0|dur�||jvr�|j|}|j|}tt��|j	|}Wd�n1s�0Yn�t
}d}|jdu}t|dd�}	|r�|	r�dj|j
|jt|�jd�}
t|
dd�|�rlt��d}t�|d�}t|j�}
|j}zt|
�|jj��}Wnt�y<t|
�}Yn0d	�|j|jt|j|jj�||�}
t|
dd�t|||||d
d�}|� ||j|�z|j!|d�W|�"||�n|�"||�0dS)
a+Create a SubRequest based on "self" and call the execute method
        of the given FixtureDef object.

        This will force the FixtureDef object to throw away any previous
        results and compute a new fixture value, which will be stored into
        the FixtureDef object itself.
        Nr�
nofuncargsFzo{name} does not support fixtures, maybe unittest.TestCase subclass?
Node id: {nodeid}
Function type: {typename})�namer^�typename�Zpytracer�z}The requested fixture has no parameter defined for test:
    {}

Requested fixture '{}' defined in:
{}

Requested here:
{}:{}Tr�r�)#rur�rIr�r�rwr~rr�r�r)r�r[rr^r]rJr6�inspect�stackZgetframeinfor9�filename�linenor��relative_tor��rootpath�
ValueErrorr'rvr��_check_scope�execute�_schedule_finalizers)r�rXruZfuncitemrdr�r�r�Z
has_paramsZfixtures_not_supportedr��frameZ	frameinfo�source_pathZ
source_linenoZsource_path_str�
subrequestrNrNrOr�]sf





*
��	
����z%FixtureRequest._compute_fixture_valuer��rXrrRcs�j���fdd��dS)Ncs�j�d�S�Nr�)�finishrN�rXrrNrO�<lambda>�r�z5FixtureRequest._schedule_finalizers.<locals>.<lambda>)r`r��r�rXrrNrrOr�sz#FixtureRequest._schedule_finalizers)ru�invoking_scope�requested_scoperRc	CsN|dkrdS||krJd�|���}td|j�d|�d|j�d|��dd�dS)	Nr��
z'ScopeMismatch: You tried to access the z scoped fixture z with a z, scoped request object, involved factories:
Fr)�join�_factorytracebackr6r�)r�rurr�textrNrNrOr
�s
����zFixtureRequest._check_scopec	Cspg}|��D]^}|j}t|�\}}t|t�rB|jj}t|j|�}n|}t	|�}|�
d||d|j|f�q|S)Nz%s:%d:  def %s%sr�)r�rvrr�rr�rQr:r�rrrJ)	r��linesrX�factory�fsrrQ�p�argsrNrNrOr�s
z FixtureRequest._factorytraceback)rdrRcCs|t|t�rt|�}|tjur$|j}n&|tjur>t|j|j�}nt|j|�}|durb|tj	urb|j}|sxJd�
||j���|S)Nz8Could not obtain a node for scope "{}" for function {!r})r�r�r<rfr�rZrcr�rnrir[)r�rdr`rNrNrOr��s



�zFixtureRequest._getscopeitemcCs
d|jS)Nz<FixtureRequest for %r>)r`r�rNrNrO�__repr__�szFixtureRequest.__repr__)2rJrKrL�__doc__�boolr��propertyrdrr�r�r`r�r-r�r�rar�r�rr�rrr�rQr�objectr�r�rr4r�rrr�r�r�rGr�r�r�rr<r
rrrh�	Collectorr�r!rNrNrNrOr��sb



	
�	N��
�c	speZdZdZdd�deeededd�dd	�Ze	d
�dd�Z
egefdd
�dd�Z
dddd��fdd�Z�ZS)r�zJA sub request for handling getting a fixture from a test function/fixture.Fr�r�rWN)r�rdr�r�rXr�rRcCsbt|�||_|j|_|tur$||_||_||_||_|j	|_	|j
|_
|j|_|j|_|j
|_
dSrS)r0r�rur�r)r�r�rIr�r�r�r�r�rU)r�r�rdr�r�rXr�rNrNrOr��s
zSubRequest.__init__r�cCsd|j�d|j�d�S)Nz<SubRequest z for �>)r�r�r�rNrNrOr!szSubRequest.__repr__r�cCs|j�|�dS)r�N)r�r�r�rNrNrOr�	szSubRequest.addfinalizerrcs6|j|jvr$|�tj|jj|d��t��||�dSr)	rur�r��	functools�partialr�r�superrr��	__class__rNrOrs
�zSubRequest._schedule_finalizers)rJrKrLr"r<r�intr#r�r�r!rr%r�r�
__classcell__rNrNr+rOr��s 
���r�c@s<eZdZdZd
eeeeedd�dd�Zdd�dd	�ZdS)r�z:Could not return a requested fixture (missing or invalid).N)rur�r�rRcCs ||_||_|��|_||_dSrS)rur�r��fixturestackr�)r�rur�r�rNrNrOr�s
zFixtureLookupError.__init__�FixtureLookupErrorReprr�cCs�g}|j}|jjjg}|�tdd�|j��|j}|durF|dd�}|D]�}t|�\}}zt	�
t|��\}}	Wn0tt
tfy�d}
||
||df�YqJ0|d|�d|d���t|�D].\}}|��}|d|�|���d	�r�qJq�qJ|du�r�|jj}
t�}|jjjj}|
j��D]*\}}t|
�||��}|�r"|�|��q"|j|v�rhd
�|j�}nd|j�d�}|d
�d�t|���7}|d7}t |||||j�S)NcSs|jSrS)rv)�xrNrNrOr+r�z/FixtureLookupError.formatrepr.<locals>.<lambda>r�z+file %s, line %s: source code not availabler�zfile z, line z  �defz5 recursive dependency involving fixture '{}' detectedz	fixture 'z' not foundz
 available fixtures: {}z, z6
 use 'pytest --fixtures [testpath]' for help on them.)!rr�r�r�r��mapr/r�rrZgetsourcelinesr#�OSError�
IndexError�	TypeError�	enumerate�rstrip�lstrip�
startswithrUr�r_r^r�r{r��_matchfactoriesr�rur[rr�r0)r��tblinesZaddlinerr�r��fspathrrr�Z	error_msgr��line�fmZ	availabler�rr��faclistrNrNrO�
formatrepr'sH
�zFixtureLookupError.formatrepr)N)	rJrKrLr"rr�r�r�rArNrNrNrOr�s��r�c@sDeZdZeedfeeeeeedd�dd�Ze	dd�dd�Z
dS)	r0zos.PathLike[str]N)r�firstlinenor<�errorstringrurRcCs"||_||_||_||_||_dSrS)r<rCrrBru)r�rrBr<rCrurNrNrOr�Us
zFixtureLookupErrorRepr.__init__)�twrRcCs�|jD]}|�|���q|j�d�}|r||jtj�d|d����dd�|dd�D]"}|jtj�d|����dd�qX|��|�dt	�
|j�|jdf�dS)Nrz       rT)Zredr�z%s:%d)
r<r>r8rC�splitrZfail_marker�stripZflow_marker�osr=rrB)r�rDZtblinerr>rNrNrO�
toterminalcs
��z!FixtureLookupErrorRepr.toterminal)rJrKrLrr�r-rrr�rrHrNrNrNrOr0Ts
�r0r�cCsRt|�\}}|�d|d��}tj�|�}t|dt|���d|dd�dS)N�:r�z:

rFr)rrm�_codeZSourcer6r��indent)�fixturefuncr�rr�location�sourcerNrNrO�fail_fixturefuncvsrO�_FixtureFunc[FixtureValue])rLr�rRcCs�t|�r~ttdttddff|�}|fi|��}zt|�}Wn$tybt|j�d��d�Yn0t	�
t||�}|�|�n ttdtf|�}|fi|��}|S)N.z did not yield a value)
r(r	rrrC�next�
StopIterationr	r�r(r)�_teardown_yield_fixturer�)rLr��kwargs�	generatorZfixture_resultr�rNrNrO�call_fixture_func}s�rVr�cCs.zt|�WntyYn0t|d�dS)z�Execute 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'N)rQrRrO)rL�itrNrNrOrS�s
rSz#Callable[[str, Config], _ScopeName]r?)�scope_callable�fixture_namer�rRc
Cslz|||d�}Wn6tyF}ztd�||��|�WYd}~n
d}~00t|t�shtd�|||�dd�|S)N)rYr�zqError evaluating {} while defining fixture '{}'.
Expected a function with the signature (*, fixture_name, config)zPExpected {} to return a 'str' while defining fixture '{}', but it returned:
{!r}Fr)�	Exceptionr6r[r�r�r6)rXrYr�r��erNrNrO�_eval_scope_callable�s$���
��r\c@s�eZdZdZddeeedeedeee	gdfdfee
eeeee
eedfeegeeffdd�	d	d
�Zedd�dd
��Zegefdd�dd�Zedd�dd�Zeed�dd�Zeed�dd�Zed�dd�ZdS)r�z%A container for a fixture definition.FNrTrPr?.)	rrr\rurvrdrwrxryrRc		Cs�||_|pd|_|du|_||_||_|dur6tj}nt|�rLt|||j	�}t
|t�rptj|d|j
�d�|d�}||_||_||_t|||d�|_||_d|_g|_dS)Nrsz	Fixture '�')Zdescr�where)rZ	is_method)rUr\�has_locationrvrur<rf�callabler\r�r�r�Z	from_userrJrIrwryr%r�rxrH�_finalizers)	r�rrr\rurvrdrwrxryrNrNrOr��s(



�zFixtureDef.__init__r�cCs|jjSr�r�r�rNrNrOrd�szFixtureDef.scoper�cCs|j�|�dSrS)rarr�rNrNrOr��szFixtureDef.addfinalizerr�c
Cs�d}z||jrTz|j��}|�WqtyP}z|dur<|}WYd}~qd}~00q|r\|�W|jj}|j||d�d|_g|_n$|jj}|j||d�d|_g|_0dS)N�rXr�)rar��
BaseExceptionr`�ihookZpytest_fixture_post_finalizerrH)r�r��excrvr[rdrNrNrOrs&

�zFixtureDef.finishcCs�|jD]:}|�|�}|dkrt|t�s*J�|�tj|j|d��q|�|�}|j	dur�|j	d}||ur�|j	ddur�|j	d\}}}|�
|��n|j	d}	|	S|�|�|j	dus�J�|jj}
|
j
||d�}	|	S)Nr�r�r��rrb)r�r�r�r�r�r(r)r�	cache_keyrH�with_tracebackr`rd�pytest_fixture_setup)r�r�rurX�my_cache_keyrgr��val�tbr�rdrNrNrOrs&






zFixtureDef.executecCst|d�s|jS|jS)Nr�)�hasattrr�r�)r�r�rNrNrOrg7szFixtureDef.cache_keycCsd�|j|j|j�S)Nz0<FixtureDef argname={!r} scope={!r} baseid={!r}>)r[rurdr\r�rNrNrOr!:s�zFixtureDef.__repr__)FN)rJrKrLr"rr�rr<rr-rr%r#rrr�r$rdr�r�rrCrrgr!rNrNrNrOr��s.
�
$��?r�)rXr�rRcCsr|j}|jr&|jdurn|j�|j�}nH|jdurnt|d�rNt|j|jj�sN|St|j�}||jkrn|�|j�}|S)z�Get the actual callable that can be called to obtain the fixture
    value, dealing with unittest-specific instances and bound methods.Nr�)	rvrxr��__get__rmr�r�r,r&)rXr�rLrNrNrO�resolve_fixture_function@s


�

rocCs�i}|jD]B}|�|�}|jdus&J�|j\}}}|�||j|j�|||<q
t||�}|�|�}	zt|||�}Wn^ty�t	�
�}
|
ddus�J�t|
dtj
�r�|j�d�s�d|
d_d|	|
f|_�Yn0||	df|_|S)zExecution of fixture setup.Nrr�Zxunit_setupT)r�r�rHr
rIrorgrVr8�sys�exc_infor�r7rZrJr:Z_use_item_location)rXr�rTruZfixdefr�Z
arg_cache_keyrerLrjrqrNrNrOri[s0





�
�
ri)ryrRcCs |durdSt|�r|St|�SrS)r`�tuple)ryrNrNrO�_ensure_immutable_idsxs
rs)rwrRcCs|durt|�SdSrS)rr)rwrNrNrO�_params_converter�srt)r��fixture_markerrRcs>dj|jp|jd��t�|��fdd��}t|�|_tt|�S)z�Wrap the given fixture function so we can raise an error about it being called directly,
    instead of used as an argument in a test function.asFixture "{name}" 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-directly about how to update your code.�rcst�dd�dS)NFrr5)r rT��messagerNrOr��sz=wrap_function_to_error_out_if_called_directly.<locals>.result)	r[rrJr(�wrapsr Z__pytest_wrapped__r	rD)r�rur�rNrwrO�-wrap_function_to_error_out_if_called_directly�s�
�
rzc@s�eZdZUded<eeedfed<dZeed<dZ	ee
eeedfeegeeffed<dZ
eeed	<dZejeed
<edd�dd
�Zeed�dd�ZdS)r��6Union[_ScopeName, Callable[[str, Config], _ScopeName]]rd.rwF�autouseNryrr�r�cCst|�dSrSr/)r�r�rNrNrO�
__post_init__�sz#FixtureFunctionMarker.__post_init__)r�rRcCsht�|�rtd��t|dd�r&td��t||�}|jp:|j}|dkr^t|�}td�	|�dd�||_
|S)Nz2class fixtures not supported (maybe in the future)r�Fz<fixture is being applied more than once to the same functionr�zA'request' is a reserved word for fixtures, use another name:
  {}r)rZisclassr	r�rzrrJr'r6r[r�)r�r�rrMrNrNrO�__call__�s$
�
��zFixtureFunctionMarker.__call__)rJrKrLrMrrr%r|r#ryrrrrr�r��dataclassesZInitVarr}rDr~rNrNrNrOr��s
�$��rdrwr|ryrr{)�fixture_functionrdrwr|ryrrRcCsdSrSrN�r�rdrwr|ryrrNrNrO�fixture�sr�cCsdSrSrNr�rNrNrOr��sr�FcCsPt||durt|�nd||dur$dnt|�r0|nt|�|dd�}|rL||�S|S)a�Decorator 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_<fixturename>`` and then use
        ``@pytest.fixture(name='<fixturename>')``.
    NT)rdrwr|ryrr�)r�rrr`)r�rdrwr|ryrrurNrNrOr��s=�
cGs,tjtdd�t|g|�R|||||d��S)z�(Return a) decorator to mark a yield-fixture factory function.

    .. deprecated:: 3.0
        Use :py:func:`pytest.fixture` directly instead.
    rf)�
stacklevelr�)�warnings�warnr1r�)r�rdrwr|ryrr rNrNrO�
yield_fixture5s���r�rQr�cCs|jS)z�Session-scoped fixture that returns the session's :class:`pytest.Config`
    object.

    Example::

        def test_foo(pytestconfig):
            if pytestconfig.getoption("verbose") > 0:
                ...

    )r�r�rNrNrO�pytestconfigOsr�)�parserrRcCs|jddgdd�dS)N�usefixturesr z5List of default fixtures to be used with this project)r]r��help)Zaddini)r�rNrNrO�pytest_addoption^s�r�c@s>eZdZdZeZeZddd�dd�Zeje	e
d�dd	�Zd*ejee
d�dd
�Zedd�dd�Ze
ee
d�dd�Zd+ee
dfejee
eee
dfe	e
ee
eeeffd�dd�Zddd�dd�Ze	ejdd�dd�Zed fedd!�d"d#�Ze
e
eeeed$�d%d&�Ze eee
eeed'�d(d)�Z!dS),rTa�pytest 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:

    - ini-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.
    r@NrPcCsB||_|j|_i|_t�|_d|j�d�i|_|jj�|d�dS)Nrsr�Z
funcmanage)	rQr�r�r��_holderobjseenZgetini�_nodeid_autousenamesZ
pluginmanager�register)r�rQrNrNrOr��s�zFixtureManager.__init__)r`rRcCsJg}|jdd�D]4}|j�dd�stj|ji|j��\}}|�|�q|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.
        �parametrizerv�indirectF)�iter_markersrTr�r3�_parse_parametrize_argsr r�)r�r`Zparametrize_argnamesr�Z
p_argnamesr�rNrNrO�_get_direct_parametrize_args�s	��
z+FixtureManager._get_direct_parametrize_argsT)r`rzrRcCsz|r"t|dd�s"t||j|d�}nd}tdd�|jdd�D��}||}|jj}|j|||�|�d	�\}}	}
t	|||	|
�S)
Nr�F)rrarNcss|]}|jD]
}|VqqdSrS)r )r��mark�argrNrNrOr��sz0FixtureManager.getfixtureinfo.<locals>.<genexpr>r�rv)�ignore_args)
r�r%rrrr�rQrU�getfixtureclosurer�r�)r�r`rvrarzr�r�r�r?r�r�rNrNrO�getfixtureinfo�s
��zFixtureManager.getfixtureinfo)�pluginrRcCs�d}zt|j�}Wnty$Ynf0|j�d�r�zt|j�|jj	��}Wnt
y`d}Yn0|dkrnd}tjt
jkr�|�tjt
j�}|�||�dS)Nzconftest.pyrs�.)r9�__file__r�rr:r�r_rr�rr	rG�seprZSEP�replace�parsefactories)r�r�r^rrNrNrO�pytest_plugin_registered�s
z'FixtureManager.pytest_plugin_registered)r^rRccs.t�|�D]}|j�|�}|r
|EdHq
dS)z:Return the names of autouse fixtures applicable to nodeid.N)r�iterparentnodeidsr�r�)r�r^ZparentnodeidZ	basenamesrNrNrO�_getautousenames�szFixtureManager._getautousenamesrN.)r��
parentnoder�rRcs�|j}t|�|���ttdd��fdd�}||�t��}i�d}|t��kr�t��}�D]>}||vrjq\|�vrtq\|�||�}	|	r\|	�|<||	dj�q\qDtt	d��fdd�}
�j
|
dd	�|��fS)
N)�	otherlistrRcs |D]}|�vr��|�qdSrS)r)r�r�)�fixturenames_closurerNrO�merge�sz/FixtureManager.getfixtureclosure.<locals>.merger�)�arg_namerRcs4z�|}Wnty$tjYS0|djSdS)Nr�)r�r<rfrI)r�r�)r�rNrO�
sort_by_scopes
z7FixtureManager.getfixtureclosure.<locals>.sort_by_scopeT)r�r�)r^r�r�r
r�rrr}r�r�r<�sort)r�r�r�r�r�r�r�Zlastlenrur�r�rN)r�r�rOr��s*
z FixtureManager.getfixtureclosurerB)rqrRc	s�tttd�dd��|jD]|�|j���}|s0qt��fdd�|j�d�D��rRqt	|�D]:}|j
dur�|j�|j
d|j|j
d	�q�|jvrZqqZqdS)
zLGenerate new tests based on parametrized fixtures used by the given metafunc)r�rRcSstj|ji|j��\}}|SrS)r3r�r rT)r�r r�rNrNrO�get_parametrize_mark_argnamesszKFixtureManager.pytest_generate_tests.<locals>.get_parametrize_mark_argnamesc3s|]}��|�vVqdSrSrN)r�r��rur�rNrOr�s�z7FixtureManager.pytest_generate_tests.<locals>.<genexpr>r�NT)r�rdry)r2rr�r�r�r��anyZ
definitionr�r�rwr�rdryr�)r�rqZfixture_defsrXrNr�rO�pytest_generate_testss*

�
�
z$FixtureManager.pytest_generate_testsr�cCst|�|dd�<dSrS)r�)r�r{rNrNrO�pytest_collection_modifyitems8sz,FixtureManager.pytest_collection_modifyitemsF)rxrRcCs"|tur|}n|j}|j}||jvr(dS|j�|�g}t|�D]�}t|tj�rZ|dkrZq@t	||d�}t
|�}t|t�szq@|jr�|j}t
||�}t|||||j|j||jd�}	|j�|g�}
|	jr�|
�|	�ntdd�|
D��}|
�||	�|jr@|�|�q@|�r|j�|�pdg��|�dS)Nr=rtcSsg|]}|js|�qSrN)r_)r��frNrNrOr�tr�z1FixtureManager.parsefactories.<locals>.<listcomp>rs)r)r�r^r�r��dirr�r�Noder+r�r�rr$r�rdrwryr�r|r_rr}�insertr|r�r�)r�Znode_or_objr^rxZ	holderobjZautousenamesrr�r�Zfixture_defr@r�rNrNrOr�<sJ


�zFixtureManager.parsefactories)rur^rRcCs4z|j|}Wnty"YdS0t|�||��S)z�Get a list of fixtures which are applicable to the given node id.

        :param str argname: Name of the fixture to search for.
        :param str nodeid: Full node id of the requesting test.
        :rtype: Sequence[FixtureDef]
        N)r�r�rrr;)r�rur^r�rNrNrOr�|s
	zFixtureManager.getfixturedefs)r�r^rRccs,tt�|��}|D]}|j|vr|VqdSrS)r�rr�r\)r�r�r^Z
parentnodeidsrXrNrNrOr;�s
zFixtureManager._matchfactories)T)rN)"rJrKrLr"r�r0r�rr�rr�r�r#r�r�r,r�rr�rrr
r�rr�r�rhr�r)r�rr�r
r;rNrNrNrOrTgs@���
(�5-��A�
�).)N)N)�rr(rrGrpr��collectionsrr�
contextlibr�pathlibr�typesr�typingrrr	r
rrr
rrrrrrrrrrrrrmrZ
_pytest._coderZ_pytest._code.coderrZ_pytest._iorZ_pytest.compatrr r!r"r#r$r%r&r'r(r)r*r+Z_pytest.configr,r-Z_pytest.config.argparsingr.Z_pytest.deprecatedr0r1Z_pytest.markr2r3Z_pytest.mark.structuresr4Z_pytest.outcomesr6r7r8Z_pytest.pathlibr9r:Z
_pytest.scoper;r<Z
_pytest.stashr=r>r?Z_pytest.mainr@rerArBrCr%rDZ_FixtureFuncrcZ_FixtureCachedResultZ	dataclassrGrVrcr�rhr&rnr�r�r�r�Z_Keyr�r�r�r�r�r�r�r��LookupErrorr�r0rOrVrSr\r�rorirsrtrzr�r#r�r�r�r�rTrNrNrNrO�<module>s� �������
��F
$��.(c08"�
���$(�
��
(�
 ����
 ����
 �
�N��	

Youez - 2016 - github.com/yon3zu
LinuXploit