HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/_pytest/__pycache__/python.cpython-310.pyc
o

%we��@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm 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+m,Z,ddl-m.Z.ddl/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=dd-l>m?Z?dd.l>m@Z@dd/l>mAZAdd0lBmCZCdd1lDmEZEdd2lDmFZFdd3lDmGZGdd4lHmIZIdd5lJmKZKdd6lLmMZMdd7lLmNZNdd8lOmPZPdd9lOmQZQdd:lOmRZRdd;lOmSZSdd<lTmUZUdd=lTmVZVdd>lWmXZXdd?lWmYZYdd@lWmZZZddAlWm[Z[ddBlWm\Z\ddClWm]Z]ddDl^m_Z_ddEl`maZaddFl`mbZbddGl`mcZce�r�ddHldmeZeddIl^mfZfee!jg�jhZidJeCdKdfdLdM�ZjdNe?dKee eke@ffdOdP�Zld�dSdT�ZmdNe?dKdfdUdV�ZndWeodKdfdXdY�ZpeAdZd[�d\d]dKeeqfd^d_��Zrd`edae#jsdKedbfdcdd�ZtdeedfeeodKeufdgdh�ZvdiedKdbfdjdk�ZweAdZd[�dle dmdneodoeqdKe de#jxe#jsee e#jxe#jsfffdpdq��ZyGdrds�dse#jz�Z{Gdtdu�du�Z|e}�~e}�ee��dv��hdw�ee|�ee|���Z�[|Gdxdy�dye{e#js�Z�Gdzdb�dbe#j�e��Z�Gd{d|�d|e��Z�d�d}d~�Z�doeqdeeodKeeqfd�d��Z�Gd�d��d�e��Z�Gd�d��d��Z�dneodKeqfd�d��Z�doeqdKeufd�d��Z�doeqdKeufd�d��Z�e2ej�dZd��Gd�d��d����Z�e2ej�dZd��Gd�d��d����Z�e2Gd�dR�dR��Z�d�eeod�eeoee"j�eqfd�e eueeofdKe_fd�d��Z�d�e eoe�fdNee?dKeofd�d��Z�dKeofd�d��Z�d�d��Z�dNe?d�eKdKdfd�d��Z�dNe?dKe eke@ffd�d��Z�dNe?d�eKdKdfd�d��Z�d�d�e,d�eod�eodKdfd�d��Z�Gd�d]�d]e{e#jx�Z�Gd�d��d�e��Z�dS)�z7Python test discovery, setup and run of test functions.�N)�Counter)�defaultdict)�partial)�Path)�Any)�Callable)�Dict)�	Generator)�Iterable)�Iterator)�List)�Mapping)�Optional)�Pattern)�Sequence)�Set)�Tuple)�
TYPE_CHECKING)�Union)�fixtures)�nodes)�filter_traceback)�getfslineno)�
ExceptionInfo)�TerminalRepr)�	Traceback)�TerminalWriter)�saferepr)�
ascii_escaped)�assert_never)�final)�get_default_arg_names)�
get_real_func)�	getimfunc)�getlocation)�is_async_function)�is_generator)�LEGACY_PATH)�NOTSET��safe_getattr)�safe_isclass)�STRING_TYPES)�Config)�ExitCode)�hookimpl)�Parser)�check_ispytest)�INSTANCE_COLLECTOR)�NOSE_SUPPORT_METHOD)�FuncFixtureInfo)�Session)�MARK_GEN)�ParameterSet)�get_unpacked_marks)�Mark)�
MarkDecorator)�normalize_mark_list)�fail)�skip)�bestrelpath��
fnmatch_ex)�import_path)�ImportPathMismatchError)�parts)�visit)�Scope)�PytestCollectionWarning)�PytestReturnNotNoneWarning)�PytestUnhandledCoroutineWarning)�Literal)�
_ScopeName�parser�returncCs�|�d�}|jddddddd�|jd	dd
ddd�|jdd
ddgdd�|jdd
dgdd�|jdd
dgdd�|jddddd�dS)N�generalz
--fixturesz
--funcargs�
store_true�showfixturesFziShow available fixtures, sorted by plugin appearance (fixtures with leading '_' are only shown with '-v'))�action�dest�default�helpz--fixtures-per-test�show_fixtures_per_testzShow fixtures per test�python_files�argsz	test_*.pyz	*_test.pyz9Glob-style file patterns for Python test module discovery)�typerRrS�python_classes�Testz6Prefixes or glob names for Python test class discovery�python_functions�testzDPrefixes or glob names for Python test function and method discovery�Ddisable_test_id_escaping_and_forfeit_all_rights_to_community_support�boolzcDisable string escape non-ASCII characters, might cause unwanted side effects(use at your own risk))�getgroup�	addoption�addini)rK�group�rb�G/home/arjun/projects/env/lib/python3.10/site-packages/_pytest/python.py�pytest_addoption\sP
�	����
�rd�configcCs,|jjr
t|�dS|jjrt|�dSdS)Nr)�optionrOrT�rerbrbrc�pytest_cmdline_main�srh�metafunc�MetafunccCs4|jjdd�D]}|j|ji|j�d|i��qdS)N�parametrize��name�_param_mark)�
definition�iter_markersrkrV�kwargs)ri�markerrbrbrc�pytest_generate_tests�s�rscCs|�dd�|�dd�dS)N�markersa�parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.z�usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures )�addinivalue_linergrbrbrc�pytest_configure�s��rv�nodeidcCsVd}|d7}|d7}|d7}|d7}|d7}|d7}t�t|�|���tdd	�dS)
NzFasync def functions are not natively supported and have been skipped.
zMYou need to install a suitable plugin for your async framework, for example:
z
  - anyio
z  - pytest-asyncio
z  - pytest-tornasync
z  - pytest-trio
z  - pytest-twistedz?async def function and no async plugin installed (see warnings))�reason)�warnings�warnrH�formatr=)rw�msgrbrbrc�async_warn_and_skip�s�r}T)�trylast�
pyfuncitem�Functioncs�|j}t|�rt|j�|j��fdd�|jjD�}|d	i|��}t|d�s+t|d�r2t|j�dS|durEt�	t
d|j�d|�d���dS)
Ncsi|]}|�|�qSrbrb)�.0�arg��funcargsrbrc�
<dictcomp>�sz&pytest_pyfunc_call.<locals>.<dictcomp>�	__await__�	__aiter__zExpected None, but z
 returned zj, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?Trb)�objr%r}rwr��_fixtureinfo�argnames�hasattrryrzrG)r�testfunction�testargs�resultrbr�rc�pytest_pyfunc_call�s 

���r��	file_path�parent�ModulecCsT|jdkr(|j�|�st||j�d�dg�sdS|j�|�}|j||d�}|SdS)Nz.pyrU�__init__.py)�module_pathr�)�suffix�session�
isinitpath�path_matches_patternsre�getini�gethookproxy�pytest_pycollect_makemodule)r�r��ihook�modulerbrbrc�pytest_collect_file�s
��r��path�patternscst�fdd�|D��S)zKReturn whether path matches any of the patterns in the list of globs given.c3s�|]}t|��VqdS�Nr?)r��pattern�r�rbrc�	<genexpr>���z(path_matches_patterns.<locals>.<genexpr>)�any)r�r�rbr�rcr��sr�r�cCs.|jdkrtj||d�}|Stj||d�}|S)Nr�r�)rm�Package�from_parentr�)r�r��pkg�modrbrbrcr��s

r��	collector)r��Classrmr�cCst|ttf�s
Jt|���t|�r#|�||�r!tj|||d�}|SdS|�||�r�t|d|�}t	�
|�sTt	�
t|��sTt|�\}}t
jtd|�dt|�|dd�dSt|dd�r�t|�r~tj||d�}d	j|d�}|�tjd
|d��|�t|��|St|�||��SdS)N)rmr��__func__z/cannot collect %r because it is not a function.�)�message�category�filename�lineno�__test__Trlz?yield tests were removed in pytest 4.0 - {name} will be ignoredF)�runrx)�
isinstancer�r�rWr+�istestclassr��istestfunction�getattr�inspect�
isfunctionr"rry�
warn_explicitrF�strr&r�r{�
add_markerr6�xfailrz�list�
_genfunctions)r�rmr��klassr�r��resrxrbrbrc�pytest_pycollect_makeitem�s<�����r�c@s�eZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	e	j
dd
��Z	dd
�Zddedede
fdd�Zdeede
feee
ffdd�ZdS)�
PyobjMixinz�this mix-in inherits from Node to carry over the typing information

    as its intended to always mix in before a node
    its position in the mro is unaffectedTcC�|�t�}|dur|jSdS)z@Python module object this node was collected from (can be None).N)�	getparentr�r���self�noderbrbrcr��
zPyobjMixin.modulecCr�)z?Python class object this node was collected from (can be None).N)r�r�r�r�rbrbrc�cls!r�zPyobjMixin.clscCs$|�t�}|durt|jdd�SdS)z�Python instance object the function is bound to.

        Returns None if not a test method, e.g. for a standalone test function,
        a staticmethod, a class or a module.
        N�__self__)r�r�r�r�r�rbrbrc�instance's
zPyobjMixin.instancecCsVt|dd�}|dur)|��|_}|jr)|j�t|j��|j�	dd�|jD��|S)zUnderlying Python object.�_objNcs��|]}|j|fVqdSr�rl�r��markrbrbrcr�=r�z!PyobjMixin.obj.<locals>.<genexpr>)
r��_getobjr��_ALLOW_MARKERS�own_markers�extendr8r��keywords�update�r�r�rbrbrcr�1szPyobjMixin.objcCs
||_dSr�)r�)r��valuerbrbrcr�@s
cCs"|jdusJ�|jj}t||j�S)zCGet the underlying Python object. May be overwritten by subclasses.N)r�r�r�rmr�rbrbrcr�DszPyobjMixin._getobjF�stopatmodule�
includemodulerLcCsp|��}|��g}|D]"}|j}t|t�r)tj�|�d}|r)|r'|�|�n|�|�q|��d�	|�S)z5Return Python path relative to the containing module.r�.)
�	listchain�reversermr�r��osr��splitext�append�join)r�r�r��chainrCr�rmrbrbrc�
getmodpathKs


zPyobjMixin.getmodpathzos.PathLike[str]cCs�|j}t|dd�}t|t�r+tj|jj}|dusJ�|�d�r&|dd�}|}|}nt	|�\}}|�
�}t|t�s<J�|||fS)N�compat_co_firstlinenoz.pyc���)r�r�r��int�sys�modules�
__module__�__file__�endswithrr�)r�r�r�r�r�r��modpathrbrbrc�
reportinfo\s


zPyobjMixin.reportinfoN)TF)�__name__r��__qualname__�__doc__r��propertyr�r�r�r��setterr�r]r�r�rrrr�r�rbrbrbrcr�s 


	

(r�c@seZdZdS)�_EmptyClassN)r�r�r�rbrbrbrcr�ssr��empty_module>r��
__cached__�__builtins__c@s�eZdZdedefdd�Zdedefdd�Zdedefdd	�Zdededefd
d�Z	dededefdd
�Z
dededefdd�Zdee
ejejffdd�Zdededfdd�ZdS)�PyCollectorrmrLcC�|�d|�S)NrZ��_matches_prefix_or_glob_option�r�rmrbrbrc�funcnamefilter��zPyCollector.funcnamefilterr�cCst|dd�duS)zgLook for the __test__ attribute, which is applied by the
        @nose.tools.istest decorator.
        r�FTr)r�rbrbrc�
isnosetest�szPyCollector.isnosetestcCr�)NrXr�r�rbrbrc�classnamefilter�r�zPyCollector.classnamefiltercCsH|�|�s
|�|�r"t|ttf�rt|dd�}t|�o!t�|�duSdS)Nr�F)	r�r�r��staticmethod�classmethodr*�callabler�getfixturemarker�r�r�rmrbrbrcr��s
zPyCollector.istestfunctioncCs|�|�p	|�|�Sr�)rr�rrbrbrcr��szPyCollector.istestclass�option_namecCsP|j�|�D]}|�|�rdSd|vsd|vsd|vr%t�||�r%dSqdS)z`Check if the given name matches the prefix or glob-pattern defined
        in ini configuration.T�*�?�[F)rer��
startswith�fnmatch)r�rrmrfrbrbrcr��s
��z*PyCollector._matches_prefix_or_glob_optioncCs�t|jdd�s	gSt|jdi�g}t|jt�r$|jjD]}|�|j�qt�}g}|j}|D]@}g}t	|�
��D]0\}}	|tvrAq8||vrFq8|�|�|j
|||	d�}
|
durXq8t|
t	�rc|�|
�q8|�|
�q8|�|�q.g}t|�D]}|�|�qu|S)Nr�T�__dict__)r�rmr�)r�r�r�rW�__mro__r�r�setr�r��items�IGNORED_ATTRIBUTES�addr�r��reversed)r��dicts�basecls�seen�dict_valuesr��dic�valuesrmr�r�r�rbrbrc�collect�s<
�
zPyCollector.collectr�c	cs,�|�t�}|dusJ�|j}|�t�}|r|jpd}tj|||d�}|j}t|||j||dd�}	g}
t	|d�r>|
�
|j�|durNt	|d�rN|
�
|�j�|jj�
|
t|	d��|	jsgtj|||d�VdS|jj}t�||	|�|��|	jD]}|�d|j�d�}
tj||
|||jdi|d	�VqydS)
N)rm�callobjT)ro�fixtureinforer�r��	_ispytestrs)ri)rmrr	�])rm�callspecrr��originalname)r�r�r�r��FunctionDefinitionr�r�rjrer�r�rsr��
call_extra�dict�_callsr�r��_fixturemanagerr�add_funcarg_pseudo_fixture_def�prune_dependency_tree�id)r�rm�funcobj�	modulecolr��clscolr�rorri�methods�fmr�subnamerbrbrcr��sL�

�


��zPyCollector._genfunctionsN)r�r�r�r�r]r��objectr�rr�r�r�r
rr�Item�	Collectorrrr�rbrbrbrcr��s		+r�csZeZdZdZdd�Zdeeejej	ff�fdd�Z
ddd	�Zdd
d�Zdd
�Z
�ZS)r�z<Collector for test classes and functions in a Python module.cC�|��Sr�)�_importtestmodule�r�rbrbrcr��zModule._getobjrLcs(|��|��|jj�|�t���Sr�)�_inject_setup_module_fixture�_inject_setup_function_fixturer�r$�parsefactories�superrr3��	__class__rbrcrs
zModule.collectNcs�|jj�d�}t|jd���dur|rt|jd��t��sd�t|jd���dur7|r7t|jd��t��s7d��durA�durAdStjddd	|jj��d
�dt	df��fd
d��}||j_
dS)a'Inject a hidden autouse, module scoped fixture into the collected module object
        that invokes setUpModule/tearDownModule if either or both are available.

        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with
        other fixtures (#517).
        �nose��setUpModule�setup_moduleN)�setup��tearDownModule�teardown_module)�teardownTr��_xunit_setup_module_fixture_��autouse�scopermrL�NNNc3s8��durt�|j�dV�durt�|j�dSdSr�)�_call_with_optional_argumentr���request�r>rBrbrc�xunit_setup_module_fixture4s��zGModule._inject_setup_module_fixture.<locals>.xunit_setup_module_fixture)re�
pluginmanager�
has_plugin�_get_first_non_fixture_funcr�rr�fixturer�r	�_Module__pytest_setup_module)r��has_noserMrbrLrcr5s0���z#Module._inject_setup_module_fixturecsjt|jd��t|jd���dur�durdStjddd|jj��d�dtd	f��fd
d��}||j_dS)a/Inject a hidden autouse, function scoped fixture into the collected module object
        that invokes setup_function/teardown_function if either or both are available.

        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with
        other fixtures (#517).
        )�setup_function)�teardown_functionNT�function�_xunit_setup_function_fixture_rErLrHc3sL�|jdurdVdS�durt�|j�dV�dur$t�|j�dSdSr�)r�rIrVrJ�rTrUrbrc�xunit_setup_function_fixtureQs�
�zKModule._inject_setup_function_fixture.<locals>.xunit_setup_function_fixture)rPr�rrQr�r	�_Module__pytest_setup_function)r�rYrbrXrcr6Cs��z%Module._inject_setup_function_fixturec
Cs2|j�d�}zt|j||jjd�}Wn}ty*}z|�t��j	dd��|�d}~wt
y>}z	|�d|j�|�d}~wtyy}z0t��}|j�d�dkrX|j
�t�|_
|j
ra|j	dd�n|��}t|�}|�dj|j|d	��|�d}~wtjy�}z
|jr��|�d
�|�d}~ww|jj�|�|S)Nz
--import-mode)�mode�root�short��stylez�import file mismatch:
imported module %r has this __file__ attribute:
  %s
which is not the same as the test file we want to collect:
  %s
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules�verbose�z�ImportError while importing test module '{path}'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
{traceback})r��	tracebackz�Using pytest.skip outside of a test will skip the entire module. If that's your intention, pass `allow_module_level=True`. If you want to skip a specific test or an entire class, use the @pytest.mark.skip or @pytest.mark.skipif decorators.)re�	getoptionrAr��rootpath�SyntaxError�CollectErrorr�from_current�getreprrBrV�ImportErrorrb�filterr�exconlyr�r{r=�	Exception�allow_module_levelrN�consider_module)r��
importmoder��e�exc_info�exc_repr�formatted_tbrbrbrcr2es`�������	����������	zModule._importtestmodule�rLN)r�r�r�r�r�r
rrr/r0rr5r6r2�
__classcell__rbrbr9rcr�s"

+"c	@s�eZdZdZ				ddeedejdeeddfdd�Z	dd	d
�Z
dddefd
d�Z	ddedede
ejfdd�Zdeeejejffdd�ZdS)r�zgCollector for files and directories in a Python packages -- directories
    with an `__init__.py` file.N�fspathr�r�rLc	Cs0|j}tjj|||||||d�|jjj|_dS)N)rvr�r�rer�rw)r�r�FSCollector�__init__r�r�rm)r�rvr�rer�rwr�rbrbrcrx�s�	zPackage.__init__cCsTt|jd�}|durt||j�t|jd�}|dur(tt||j�}|�|�dSdS)Nr<r@)rPr�rIr�addfinalizer)r�r>rB�funcrbrbrcr?�s���z
Package.setup�direntryzos.DirEntry[str]cCs>|jdkrdSt|j�}|j�|j�}|j||jd�rdSdS)N�__pycache__F��collection_pathreT)rmrr�r�r�r��pytest_ignore_collectre)r�r{rvr�rbrbrc�_recurse�s

zPackage._recurseT�handle_dupescCs�|��sJd�||��|��|�����|j�|�}|j�|�s*|j||j	d�r*dS|rD|j	�
d�}|sD|j	jj}||vr?dS|�
|�|j||d�S)Nz9{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})r}rb�keepduplicates)r�r�)�is_filer{�is_dir�exists�
is_symlinkr�r�r�rrercrN�_duplicatepathsrr�)r�rvr�r�r��duplicate_pathsrbrbrc�_collectfile�s$���

zPackage._collectfilec#s��|jj}t|j|j�d��rtj||jd�Vt�}tt	|�|j
d�D]F}t|j��|��r:|j
dkr:�j|kr:q$t|j��t��fdd�|D��rLq$|��rY|���EdHq$|��s^q$��d���rj|���q$dS)NrUr�)�recurser�c3s(�|]}t|��vo|d�kVqdS)r�N�r�)r��
pkg_prefix��parts_r�rbrcr��s
��
�z"Package.collect.<locals>.<genexpr>)r�r�r�rer�r�r�rrDr�r�rr�rmrCr�r�r��joinpathr)r��	this_path�pkg_prefixesr{rbr�rcr�s.�

�
��zPackage.collect)NNNNrt)T)r�r�r�r�rr'rr0rrxr?r]r�rr�r
rr/rrbrbrbrcr��s4����	
�

���
�"r�cCs4|jj}t�|�r
|d8}|r||�dS|�dS)zyCall the given function with the given argument if func accepts one argument, otherwise
    calls func without arguments.r�N)�__code__�co_argcountr��ismethod)rzr��	arg_countrbrbrcrIs

rI�namescCs8|D]}t||d�}|durt�|�dur|SqdS)z�Return the attribute from the given object to be used as a setup/teardown
    xunit-style function, but only if not marked as a fixture to avoid calling it twice.
    N)r�rr)r�r�rm�methrbrbrcrPs�rPcsheZdZdZedd��fdd�
�Zdd�Zdeee	j
e	jff�fd	d
�Zddd�Z
dd
d�Z�ZS)r�zBCollector for test methods (and nested classes) in a Python class.N�r�cst�jd||d�|��S)�The public constructor.)rmr�Nrb�r8r�)r�r�rmr��kwr9rbrcr�szClass.from_parentcCr1r�r�r3rbrbrc�newinstance!r4zClass.newinstancerLcs�t|jdd�s	gSt|j�r&|jdusJ�|�td|jj|jjf��gSt|j�rC|jdus2J�|�td|jj|jjf��gS|�	�|�
�|jj�
|��|j�t���S)Nr�TzMcannot collect test class %r because it has a __init__ constructor (from: %s)zLcannot collect test class %r because it has a __new__ constructor (from: %s))r*r��hasinitr�rzrFr�rw�hasnew�_inject_setup_class_fixture�_inject_setup_method_fixturer�r$r7r�r8rr3r9rbrcr$s4
���
���
z
Class.collectcslt�jd��t�jd���dur�durdStjddd�jj��d�dtd	f���fd
d��}|�j_dS)a%Inject a hidden autouse, class scoped fixture into the collected class object
        that invokes setup_class/teardown_class if either or both are available.

        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with
        other fixtures (#517).
        )�setup_class)�teardown_classNT�class�_xunit_setup_class_fixture_rErLrHc3sH��durt��}t|�j�dV�dur"t��}t|�j�dSdSr�)r#rIr�)r�rz�r�r�r�rbrc�xunit_setup_class_fixtureOs��zDClass._inject_setup_class_fixture.<locals>.xunit_setup_class_fixture)rPr�rrQr�r	�_Class__pytest_setup_class)r�r�rbr�rcr�Cs�	z!Class._inject_setup_class_fixturecs�|jj�d�}d�t|j�f��d��dur#|r#d�d�t|j�f��d�t|j�f��d��dur?|r?d�d�t|j�f���durI�durIdStjdd	d
|jj��d�dtd
f������fdd��}||j_	dS)a+Inject a hidden autouse, function scoped fixture into the collected class object
        that invokes setup_method/teardown_method if either or both are available.

        Using a fixture to invoke these methods ensures we play nicely and unsurprisingly with
        other fixtures (#517).
        r;�setup_methodFNr?T�teardown_methodrCrV�_xunit_setup_method_fixture_rErLrHc3s��|j}�dur"t|��}t||��r"tjtj|jjdd�dd�dV�durEt|��}t||��rGtjtj|jjdd�dd�dSdSdS)Nr?)rw�methodra)�
stacklevelrC)	rVr�rIryrzr3r{r�rw)r�rKr�rz��emit_nose_setup_warning�emit_nose_teardown_warningr��
setup_namer��
teardown_namerbrc�xunit_setup_method_fixtureys2�

��

�
��zFClass._inject_setup_method_fixture.<locals>.xunit_setup_method_fixture)
rerNrOrPr�rrQr�r	�_Class__pytest_setup_method)r�rSr�rbr�rcr�`s0�"z"Class._inject_setup_method_fixturert)r�r�r�r�rr�r�r
rrr/r0rr�r�rurbrbr9rcr�s"
r�c@seZdZdZdS)�
InstanceDummyz�Instance used to be a node type between Class and Function. It has been
    removed in pytest 7.0. Some plugins exist which reference `pytest.Instance`
    only to ignore it; this dummy class keeps them working. This will be removed
    in pytest 8.N)r�r�r�r�rbrbrbrcr��sr�cCs,|dkrt�td�tStdt�d|����)N�Instancerazmodule z has no attribute )ryrzr2r��AttributeErrorr�rlrbrbrc�__getattr__�sr�cC�t|dd�}|r
|tjkSdS)NrxF)r�r.rx)r��initrbrbrcr���
r�cCr�)N�__new__F)r�r.r�)r��newrbrbrcr��r�r�)�frozenc	@s<eZdZUdZdZeeed<eeed<e	e
ege	efed<e	ee	eed<e	e
ed<e	eed<e	eed	<d
eefdd�Zd
eefd
d�Zdededed
efdd�Zdededed
e	efdd�Zdeded
e	efdd�Zded
e	efdd�Zdeded
efdd�Zededed
efdd��ZdS)�IdMakerzMake IDs for a parametrization.)r��
parametersets�idfn�idsrerw�	func_namer�r�r�r�rerwr�rLcCsvt|���}t|�tt|��kr9t|�}tt�}t|�D]\}}||dkr8|�||��||<||d7<q|S)a�Make a unique identifier for each ParameterSet, that may be used to
        identify the parametrization in a node ID.

        Format is <prm_1_token>-...-<prm_n_token>[counter], where prm_x_token is
        - user-provided id, if given
        - else an id derived from the value, applicable for certain types
        - else <argname><parameterset index>
        The counter suffix is appended only in case a string wouldn't be unique
        otherwise.
        r�)r��_resolve_ids�lenrrrr��	enumerate)r��resolved_ids�	id_counts�id_suffixes�indexr'rbrbrc�make_unique_parameterset_ids�s�z$IdMaker.make_unique_parameterset_idsc#s��t�j�D]=\�}|jdur|jVq�jr0�t�j�kr0�j�dur0���j���Vqd���fdd�t|j�j	�D��VqdS)z;Resolve IDs for all ParameterSets (may contain duplicates).N�-c3s"�|]\}}��||��VqdSr�)�_idval)r��val�argname��idxr�rbrcr��s
��
�z'IdMaker._resolve_ids.<locals>.<genexpr>)
r�r�r'r�r��_idval_from_value_requiredr��ziprr�)r��parametersetrbr�rcr��s�

"��zIdMaker._resolve_idsr�r�r�cCsT|�|||�}|dur
|S|�||�}|dur|S|�|�}|dur$|S|�||�S)z-Make an ID for a parameter in a ParameterSet.N)�_idval_from_function�_idval_from_hook�_idval_from_value�_idval_from_argname)r�r�r�r��idvalrbrbrcr�s
zIdMaker._idvalc
Cs�|jdurdSz|�|�}Wn(ty6}z|jdur!|j�d�nd}d}||�||�}t|�|�d}~ww|dur=dS|�|�S)zjTry to make an ID for a parameter in a ParameterSet using the
        user-provided id callable, if given.N�: �zJerror raised while trying to determine id of parameter '{}' at position {})r�rlrwr{�
ValueErrorr�)r�r�r�r�r'rp�prefixr|rbrbrcr�s

��
zIdMaker._idval_from_functioncCs$|jr|jjj|j||d�}|SdS)zsTry to make an ID for a parameter in a ParameterSet by calling the
        :hook:`pytest_make_parametrize_id` hook.)rer�r�N)re�hook�pytest_make_parametrize_id)r�r�r�r'rbrbrcr�!s�zIdMaker._idval_from_hookcCs�t|t�rt||j�S|dust|ttttf�rt|�St|t	�r&t
|j�S|tur-	dSt|t
j�r7t|�Stt|dd�t�rGt|d�}|SdS)zkTry to make an ID for a parameter in a ParameterSet from its value,
        if the value type is supported.Nr�)r�r,�_ascii_escaped_by_configre�floatr�r]�complexr�rrr�r(�enum�Enumr�)r�r�rmrbrbrcr�+s


�
zIdMaker._idval_from_valuecCs�|�|�}|dur|S|jdurd|j�d�}n|jdur%d|j�d�}nd}|�dt|��dt|��d|�d�}t|d	d
�dS)zALike _idval_from_value(), but fails if the type is not supported.N�In r�r�zids contains unsupported value z (type: z) at index zf. Supported types are: str, bytes, int, float, complex, bool, enum, regex or anything with a __name__.F��pytrace)r�r�rwrrWr<)r�r�r�r'r�r|rbrbrcr�?s


"�z"IdMaker._idval_from_value_requiredcCst|�t|�S)znMake an ID for a parameter in a ParameterSet from the argument name
        and the index of the ParameterSet.r�)r�r�rbrbrcr�RszIdMaker._idval_from_argnameN)r�r�r�r��	__slots__rr��__annotations__r7rrrr.r-rr�r
r�r�r�r�r�r�r�rr�rbrbrbrcr��s6

���
�
r�c@seZdZUdZejed�Zee	e
fed<ejed�Zee	e
fed<ejed�Z
ee	efed<ejed�Zee	efed<ejed�Zee	ed<ejed�Zeeed<d	ee	d
fdee	dee
d
e	deeeefdededdfdd�Zde	de
fdd�Zede	fdd��ZdS)�	CallSpec2z�A planned parameterized invocation of a test function.

    Calculated during collection for a given test function's Metafunc.
    Once collection is over, each callspec is turned into a single Item
    and stored in item.callspec.
    )�default_factoryr��params�indices�
_arg2scope�_idlist�marks�valtypes�Literal['params', 'funcargs']r��valsetr'rG�param_indexrLc	Cs�|j��}|j��}	|j��}
|j��}t||�D]5\}}
||	vs%||vr,td|����||}|dkr9|
|	|<n
|dkrB|
||<nt|�||
|<|||<qt||	|
|g|j	�|�g|j
�t|��d�S)Nzduplicate parametrization of r�r�)r�r�r�r�r�r�)r��copyr�r�r�r�r�rr�r�r�r;)r�r�r�r�r'r�rGr�r�r�r��	arg2scoper�r��valtype_for_argrbrbrc�setmultirs.






�zCallSpec2.setmultirmc
Cs0z|j|WSty}zt|�|�d}~wwr�)r��KeyErrorr�)r�rmrprbrbrc�getparam�s
��zCallSpec2.getparamcCsd�|j�S)Nr�)r�r�r3rbrbrcr'�szCallSpec2.idN)r�r�r�r��dataclasses�fieldr"r�rr�r.r�r�r�r�r�rEr�r�rr�r9r
r
rr:r�r�r�r'rbrbrbrcr�Ys8
	
������	�

�$r�c@s�eZdZdZ		d#dd�dddejded	ed
df
dd�Z			d$dd
�de	e
ee
fdee	e
eeefde	eee
fdee	eeeeegeeffdddeed
dfdd�Zdee
dee	eeeeegeeffdee
de
d
ee
f
dd�Zdeeedee
de
d
eeefdd�Zdee
de	eee
fd
ee
dffdd �Zdee
de	eee
fd
dfd!d"�ZdS)%rjz�Objects passed to the :hook:`pytest_generate_tests` hook.

    They help to inspect a test function and to generate tests according to
    test configuration or values specified in the class or module where a
    test function is defined.
    NF�rror rrerrLcCsBt|�||_||_||_|j|_|j|_||_|j	|_
g|_dSr�)r1rorer�r�rV�
names_closure�fixturenamesr��name2fixturedefs�_arg2fixturedefsr#)r�rorrer�r�rrbrbrcrx�s

zMetafunc.__init__)rnr��	argvalues�indirectr�rGzOptional[_ScopeName]rncCs8tj|||j|j|jjd�\}}~d|vrtddd�|dur,tj|d|jj	��d�}nt
||j|�}|�||�|�
||�}	|rN|jrN|jj}
|
durN|
}|j||||jjd�}|rj|jrj|
durjt�|jd	|�g}|jprt�gD]#}tt||��D]\}
\}}|j|	||j||j||
d
�}|�|�q|qs||_dS)azAdd new invocations to the underlying test function using the list
        of argvalues for the given argnames. Parametrization is performed
        during the collection phase. If you need to setup expensive resources
        see about setting indirect to do it rather than at test setup time.

        Can be called multiple times per test function (but only on different
        argument names), in which case each call parametrizes all previous
        parametrizations, e.g.

        ::

            unparametrized:         t
            parametrize ["x", "y"]: t[x], t[y]
            parametrize [1, 2]:     t[x-1], t[x-2], t[y-1], t[y-2]

        :param argnames:
            A comma-separated string denoting one or more argument names, or
            a list/tuple of argument strings.

        :param argvalues:
            The list of argvalues determines how often a test is invoked with
            different argument values.

            If only one argname was specified argvalues is a list of values.
            If N argnames were specified, argvalues must be a list of
            N-tuples, where each tuple-element specifies a value for its
            respective argname.

        :param indirect:
            A list of arguments' names (subset of argnames) or a boolean.
            If True the list contains all names from the argnames. Each
            argvalue corresponding to an argname in this list will
            be passed as request.param to its respective argname fixture
            function so that it can perform more expensive setups during the
            setup phase of a test rather than at collection time.

        :param ids:
            Sequence of (or generator for) ids for ``argvalues``,
            or a callable to return part of the id for each argvalue.

            With sequences (and generators like ``itertools.count()``) the
            returned ids should be of type ``string``, ``int``, ``float``,
            ``bool``, or ``None``.
            They are mapped to the corresponding index in ``argvalues``.
            ``None`` means to use the auto-generated id.

            If it is a callable it will be called for each entry in
            ``argvalues``, and the return value is used as part of the
            auto-generated id for the whole set (where parts are joined with
            dashes ("-")).
            This is useful to provide more specific ids for certain items, e.g.
            dates.  Returning ``None`` will use an auto-generated id.

            If no ids are provided they will be generated automatically from
            the argvalues.

        :param scope:
            If specified it denotes the scope of the parameters.
            The scope is used for grouping tests by parameter instances.
            It will also override any fixture-function defined scope, allowing
            to set a dynamic scope using test context or configuration.
        )rwrKzK'request' is a reserved name and cannot be used in @pytest.mark.parametrizeFr�Nzparametrize() call in )�descr�_param_ids_generated)r�r�r�r'r�rGr�)r7�_for_parametrizerVrerorwr<rE�	from_userr��_find_parametrized_scoper�_validate_if_using_arg_names�_resolve_arg_value_types�_param_ids_fromr�_resolve_parameter_set_idsr.�__setattr__r#r�r�r�r�rr�r�)r�r�rrr�rGrnr��scope_�arg_values_types�
generated_ids�newcallsrr��param_id�	param_set�newcallspecrbrbrcrk�s\J
���
���	�

zMetafunc.parametrizer�rwc	Cs^|dur	d}d}nt|�r|}d}nd}|�|||jj�}t|||||j||jjd�}|��S)a:Resolve the actual ids for the given parameter sets.

        :param argnames:
            Argument names passed to ``parametrize()``.
        :param ids:
            The `ids` parameter of the ``parametrize()`` call (see docs).
        :param parametersets:
            The parameter sets, each containing a set of values corresponding
            to ``argnames``.
        :param nodeid str:
            The nodeid of the definition item that generated this
            parametrization.
        :returns:
            List with ids for each parameter set given.
        N)rwr�)r�
_validate_idsrVr�r�rer�)r�r�r�r�rwr��ids_�id_makerrbrbrcrSs$�	z#Metafunc._resolve_parameter_set_idsr�c
Cs�zt|�}Wn%ty+zt|�Wnty$}ztd�|�d}~wwt|�}Ynw|t|�krE|dkrEd}t|�|t|�|�dd�tt�||��S)Nz%ids must be a callable or an iterablerzDIn {}: {} parameter sets specified, with different number of ids: {}Fr�)r��	TypeError�iterr<r{r��	itertools�islice)r�r�r�r��num_idsrpr|rbrbrcrs
���zMetafunc._validate_idsr�cCs�t|t�rt�||rd�}|Sd�}|St|t�r:t�|d�}|D]}||vr3td�|jj|�dd�d||<q!|Stdjt	|�j|jjd�dd�|S)a�Resolve if each parametrized argument must be considered a
        parameter to a fixture or a "funcarg" to the function, based on the
        ``indirect`` parameter of the parametrized() call.

        :param List[str] argnames: List of argument names passed to ``parametrize()``.
        :param indirect: Same as the ``indirect`` parameter of ``parametrize()``.
        :rtype: Dict[str, str]
            A dict mapping each arg name to either:
            * "params" if the argname should be the parameter of a fixture of the same name.
            * "funcargs" if the argname should be a parameter to the parametrized test function.
        r�r�z*In {}: indirect fixture '{}' doesn't existFr�z@In {func}: expected Sequence or boolean for indirect, got {type})rWrz)
r�r]r"�fromkeysrr<r{rVr�rW)r�r�rr�r�rbrbrcr	�s6
���
���
���z!Metafunc._resolve_arg_value_typesc	Cs�tt|j��}|jj}|D]:}||jvrG||vr#td�||�dd�q
t|t�r1||vr.dnd}n|r5dnd}td|�d|�d|�d	�dd�q
d
S)a4Check if all argnames are being used, by default values, or directly/indirectly.

        :param List[str] argnames: List of argument names passed to ``parametrize()``.
        :param indirect: Same as the ``indirect`` parameter of ``parametrize()``.
        :raises ValueError: If validation fails.
        zCIn {}: function already takes an argument '{}' with a default valueFr�rQ�argumentr�z: function uses no z '�'N)	rr!rVr�r�r<r{r�r)r�r�r�default_arg_namesr�r�rmrbrbrcr�s(
��
���z%Metafunc._validate_if_using_arg_names)NN)FNN)r�r�r�r�rr4r-r]rxrr�rr
r7r.rrrr9rkrrrrr	rrbrbrbrcrj�s�������	
�'�
���� ���
�
�� ����
�,
���

���

�(���r��arg2fixturedefsrcsZt|t�rt|�t��k}nt|�}|r*|pi}�fdd�|��D�}t|tjd�StjS)a}Find the most appropriate scope for a parametrized call based on its arguments.

    When there's at least one direct argument, always use "function" scope.

    When a test function is parametrized and all its arguments are indirect
    (e.g. fixtures), return the most narrow scope based on the fixtures used.

    Related to issue #1832, based on code posted by @Kingdread.
    cs"g|]
\}}|�vr|dj�qS)r)�_scope)r�rm�
fixturedef�r�rbrc�
<listcomp>�s
�z,_find_parametrized_scope.<locals>.<listcomp>)rR)r�rr�r]r�minrEr�)r�r r�all_arguments_are_fixtures�fixturedefs�used_scopesrbr#rcr�s

�rr�cCs(|durd}n|�d�}|r|St|�S)NFr\)r�r)r�re�
escape_optionrbrbrcr��s�r�cCsVt��}tt|t|���}tdd�}z
t||�t��WSty*t||�YSw)Nz...�_pytest)r�cwdr$r��relative_to�_PYTEST_DIRr�r>)rzr+�locr�rbrbrc�_pretty_fixture_paths
�r/cC�ddlm}||t�S�Nr)�wrap_session)�_pytest.mainr2�_show_fixtures_per_test�rer2rbrbrcrT�
rTr�cs�ddl}|��t���|j�|��|�d��dtf�fdd��dtj	t
ddf��fdd��d	tjddf���fd
d�}|j
D]}||�q@dS)Nrr`rLcst|t���}t�t|��Sr�)r$r�r>r)rzr.)�curdirrbrc�get_best_relpath#sz1_show_fixtures_per_test.<locals>.get_best_relpath�fixture_defcs�|j}�dkr|�d�rdSt|j�}�j|�dd��jd|��dd���d�t�|j�}|rGt��dkrB|�d�d�dS|�dS�j	d	dd
�dS)Nr�_T��green� -- ��yellow�
�

�    no docstring available��red)
r�r
r/rz�writer��getdoc�write_docstring�split�line)r9r��
prettypath�fixture_doc)�twr`rbrc�
write_fixture's

��z._show_fixtures_per_test.<locals>.write_fixture�itemcs�t|dd�}|dus
|jsdS�����dd|j�����dd�|j��d��t|j���D]\}}|dus;J�|s>q1�|d�q1dS)Nr�r�zfixtures used by �(�)r�)r�r�rI�seprmrV�sortedr)rN�infor:r')r8rLrMrbrc�
write_item7s�z+_show_fixtures_per_test.<locals>.write_item)�_pytest.config�perform_collectrr+re�create_terminal_writer�getvaluer�r�
FixtureDefr.rr/r)rer�r*rT�session_itemrb)r7r8rLr`rMrcr4s


�r4cCr0r1)r3r2�_showfixtures_mainr5rbrbrcrOMr6rOc	Cs�ddl}|��t��}|j�|�}|�d�}|j}g}t�}|j	�
�D]=\}	}
|
dus.J�|
s1q$|
D]-}t|jt
|��}|j|f|vrEq3|�|j|f�|�t|j�|jjt|j�|j|f�q3q$|��d}
|D]s\}}}}	}|
|kr�|�d�s�|��|�dd|���|}
|dkr�|	�d�r�qj|j|	�dd�|jd	kr�|jd
|jdd�|jd|��dd
�|�d�t�|j�}|r�t||dkr�|�d�dn|�n|jddd�|��qjdS)Nrr`z_pytest.r�zfixtures defined from r:Tr;rVz [%s scope])�cyanr=r>r@rArBrC)rUrVrr+rerWrXr$rrrr$rzr�r�rr�r��baseidr�r/�sortr
rIrQrErGr�rFrGrH)rer�r*r7rLr`r,�	availablerr�r'r"r.�
currentmoduler]r�rJ�docrbrbrcr[Ss^
���


"
�r[�    rLra�indentcCs"|�d�D]	}|�||�qdS)Nr@)rHrI)rLrarcrIrbrbrcrG�s�rGcs�eZdZdZdZddeddddfdedeedee	dee
eefdeed	ee
d
eeddf�fdd
�
Ze�fdd��Zd!dd�Zedd��Zdd�Zedd��Zd!dd�Zd!dd�Zdeedefdd�Zdeedeeeffdd �Z�ZS)"r�a�Item responsible for setting up and executing a Python test function.

    :param name:
        The full function name, including any decorations like those
        added by parametrization (``my_func[my_param]``).
    :param parent:
        The parent Node.
    :param config:
        The pytest Config object.
    :param callspec:
        If given, this is function has been parametrized and the callspec contains
        meta information about the parametrization.
    :param callobj:
        If given, the object which will be called when the Function is invoked,
        otherwise the callobj will be obtained from ``parent`` using ``originalname``.
    :param keywords:
        Keywords bound to the function object for "-k" matching.
    :param session:
        The pytest Session object.
    :param fixtureinfo:
        Fixture information already resolved at this fixture node..
    :param originalname:
        The attribute name to use for accessing the underlying function object.
        Defaults to ``name``. Set this if name is different from the original name,
        for example when it contains decorations like those added by parametrization
        (``my_func[my_param]``).
    FNrmrerr�r�rrrLc

s�t�j||||d�|tur||_|	p||_|j�t|j��|r+||_|j�|j	�|j
�dd�|jD��|j
�|jj�|rG|j
�|�|durX|j
jj||j|jdd�}||_|j|_|��dS)N)rer�csr�r�rlr�rbrbrcr��r�z$Function.__init__.<locals>.<genexpr>Tr�)r8rxr(r�rr�r�r8rr�r�r�rr�r$�getfixtureinfor�r�r�r��_initrequest)
r�rmr�rerrr�r�rrr9rbrcrx�s&
�zFunction.__init__cst�jdd|i|��S)r�r�Nrbr�)r�r�r�r9rbrcr��szFunction.from_parentcCsi|_tj|dd�|_dS)NTr�)r�r�FixtureRequest�_requestr3rbrbrcre�szFunction._initrequestcCs
t|j�S)z$Underlying python 'function' object.)r#r�r3rbrbrcrV�s
zFunction.functioncCs:|jdusJ�t|jt�r|j��}n|jj}t||j�Sr�)r�r�r�r�r�r�r)r��
parent_objrbrbrcr��s
zFunction._getobjcCs|S)zA(compatonly) for code expecting pytest-2.2 style request objects.rbr3rbrbrc�_pyfuncitem�szFunction._pyfuncitemcCs|jj|d�dS)z%Execute the underlying test function.)rN)r�r�r3rbrbrc�runtest�szFunction.runtestcCs|j��dSr�)rg�
_fillfixturesr3rbrbrcr?szFunction.setup�excinfocs�t|d�ra|j�dd�satjj�t|j��}|j	|j
}}|j}|j||d���|kr>�j|d���|kr>��
t���s>|���
|��|j�dd�dkr_t��dkr_t�fd	d
�t��D����S|jS)Nr��	fulltraceF)r��firstlinenor��tbstyle�autorac3s:�|]\}}|dks|t��dkr|n|�d�VqdS)rr�r]N)r��with_repr_style)r��i�entry��
ntracebackrbrcr�s���
�z-Function._traceback_filter.<locals>.<genexpr>)r�rercr*�_code�Code�
from_functionr"r�r�rnrb�cutrjrr�rr�)r�rl�coder�rnrbrbrtrc�_traceback_filters&

�zFunction._traceback_filtercCs(|j�dd�}|dkr
d}|j||d�S)Nrorp�longr^)rerc�_repr_failure_py)r�rlr_rbrbrc�repr_failure"szFunction.repr_failurert) r�r�r�r�r�r(r�rr-r�r
rr5r4rxrr�rer�rVr�rirjr?r�
BaseExceptionrr{rrr~rurbrbr9rcr��sV������	�
��3

	


�
�c@seZdZdZddd�ZeZdS)r z�This class is a stop gap solution until we evolve to have actual function
    definition nodes and manage to get rid of ``metafunc``.rLNcCstd��)Nz8function definitions are not supposed to be run as tests)�RuntimeErrorr3rbrbrcrj0r4zFunctionDefinition.runtestrt)r�r�r�r�rjr?rbrbrbrcr ,s
r )rirjrLNrt)rb)�r�r�r�rr�rr�r��typesry�collectionsrr�	functoolsr�pathlibr�typingrrrr	r
rrr
rrrrrrrr*rr�
_pytest._coderr�_pytest._code.coderrr�_pytest._ior�_pytest._io.safereprr�_pytest.compatrrr r!r"r#r$r%r&r'r(r*r+r,rUr-r.r/�_pytest.config.argparsingr0�_pytest.deprecatedr1r2r3�_pytest.fixturesr4r3r5�_pytest.markr6r7�_pytest.mark.structuresr8r9r:r;�_pytest.outcomesr<r=�_pytest.pathlibr>r@rArBrCrD�
_pytest.scoperE�_pytest.warning_typesrFrGrH�typing_extensionsrIrJr�r�r-rdr�rhrsrvr�r}r.r�r0r�r]r�r�r/r��Noder�r��	frozenset�union�dir�
ModuleTyperr��Filer�r�rIrPr�r�r�r�r��	dataclassr�r�rjrYr�bytesr�r/rTr4rOr[rGr�r rbrbrbrc�<module>s:.

���"�'`�


m
"
F>���
�" 

27