Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/_pytest/__pycache__/main.cpython-37.pyc

B

C$�Xjl�@s�dZddlZddlZddlZddlZddlZddlZddlZyddlm	Z
Wn ek
rlddlm
Z
YnXddlmZddlmZej�ej���ZdZdZdZd	Zd
ZdZdd
�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gdd�d�Z&Gd d!�d!e'�Z(Gd"d#�d#e
�Z)Gd$d%�d%e'�Z*Gd&d'�d'e*�Z+Gd(d)�d)e+�Z,Gd*d+�d+e,�Z-Gd,d-�d-e*�Z.Gd.d/�d/e/�Z0Gd0d1�d1e1�Z2Gd2d3�d3e,�Z3dS)4zF core implementation of testing process: init, session, runtest loop. �N)�MutableMapping)�	DictMixin)�
directory_arg)�collect_one_node�����cCsV|jddddddddd	d
gd�|jdd
dgd�|�dd�}|jddddddd�f|jdddtdddd�|jdddd �|jd!d"td#d$d%�|jd&dd'd(d)d*�|�d+d,�}|jd-d.dd/d �f|jd0dd1d �|jd2d3d4d5d6�|jd7d8dd9tjtd7d:�d;d<�|jd=dd>d'd?d@�|jdAdBddCd'dDd@�|�dEdF�}|jdGdHdd9dIdJ�dS)KN�
norecursedirsz)directory patterns to avoid for recursion�argsz.*�build�distZCVSZ_darcsz{arch}z*.egg)�type�defaultZ	testpathsz[directories to search for tests when no files or directories are given in the command line.Zgeneralzrunning and selection optionsz-xz--exitfirstZstore_const�maxfailrz-exit instantly on first error or failed test.)�action�dest�const�helpz	--maxfail�num�storerz(exit after first num failures or errors.)�metavarrrrrrz--strict�
store_truez2run pytest in strict mode, warnings become errors.)rrz-c�fileZinifilenamezcload configuration from `file` instead of trying to locate one of the implicit configuration files.)rrrrz--continue-on-collection-errorsF�continue_on_collection_errorsz5Force test execution even if collection errors occur.)rrrr�collect�
collectionz
--collectonlyz--collect-onlyz'only collect tests, don't execute them.z--pyargsz2try to interpret all arguments as python packages.z--ignore�append�pathz.ignore path during collection (multi-allowed).)rrrz--confcutdirZ
confcutdir�dir)�optnamez2only load conftest.py's relative to specified dir.)rrrrrz--noconftestZ
noconftestz!Don't load any conftest.py files.)rrrrz--keepduplicatesz--keep-duplicates�keepduplicateszKeep duplicate tests.Zdebugconfigz(test session debugging and configurationz
--basetempZbasetempz+base temporary directory for this test run.)rrrr)	ZaddiniZgetgroupZ
_addoption�int�strZ	addoption�	functools�partialr)�parser�group�r)�=/opt/alt/python37/lib/python3.7/site-packages/_pytest/main.py�pytest_addoptionsL







r+cCstttttd�}t|d�S)N)�Item�	Collector�File�Session)r)�dictr,r-r.r/)rr)r)r*�pytest_namespaceNsr1cCs
|t_dS)N)�pytest�config)r3r)r)r*�pytest_configureSsr4c
Cs>t|�}t|_d}z�y2|��d}|jj|d�d}|||�p@d|_Wn�tjk
r^�Yn�tk
r�t	j
��}|dkr�t|j
tjj�r�tj�d�|j|j
j��|jj|d�t|_Yn@t	j
��}|�||j�t|_|�t�r�tj�d�YnXWdd}|j��|dk�r.|jj||jd	�|� �X|jS)
zSkeleton command line programrr)�sessionrz	{0}: {1}
)�excinfoz&mainloop: caught Spurious SystemExit!
N)r5�
exitstatus)!r/�EXIT_OKr7Z
_do_configure�hookZpytest_sessionstartr2�
UsageError�KeyboardInterrupt�_pytest�_codeZ
ExceptionInfo�
isinstance�value�exit�	Exception�sys�stderr�write�format�typename�msgZpytest_keyboard_interrupt�EXIT_INTERRUPTEDZnotify_exception�option�EXIT_INTERNALERROR�
errisinstance�
SystemExit�startdir�chdirZpytest_sessionfinishZ_ensure_unconfigure)r3Zdoitr5Z	initstater6r)r)r*�wrap_sessionWsD









rOcCs
t|t�S)N)rO�_main)r3r)r)r*�pytest_cmdline_main~srQcCs8|jj|d�|jj|d�|jr&tS|jdkr4tSdS)z] default command line protocol for initialization, session,
    running tests and reporting. )r5rN)r9�pytest_collection�pytest_runtestloop�testsfailed�EXIT_TESTSFAILED�testscollected�EXIT_NOTESTSCOLLECTED)r3r5r)r)r*rP�s
rPcCs|��S)N)�perform_collect)r5r)r)r*rR�srRcCs�|jr |jjjs |�d|j��|jjjr.dSx^t|j�D]P\}}|dt|j�krb|j|dnd}|jj	j
||d�|jr:|�|j��q:WdS)Nz%d errors during collectionTr)�item�nextitem)rTr3rIr�InterruptedZcollectonly�	enumerate�items�lenr9Zpytest_runtest_protocol�
shouldstop)r5�irYrZr)r)r*rS�s

$rScCs||��}|jd|d�}|pg}|�d�}|r@|�dd�|D��||krLdS|�d�}|jj}|sx||krndS|�|�dS)	NZcollect_ignore)r�ignorecSsg|]}tj�|��qSr))�pyr�local)�.0�xr)r)r*�
<listcomp>�sz)pytest_ignore_collect.<locals>.<listcomp>Tr"F)�dirpathZ_getconftest_pathlistZ	getoption�extend�
pluginmanagerZ_duplicatepaths�add)rr3�pZignore_pathsZ
excludeoptr"Zduplicate_pathsr)r)r*�pytest_ignore_collect�s


rlc@seZdZdd�Zdd�ZdS)�FSHookProxycCs||_||_||_dS)N)�fspath�pm�remove_mods)�selfrnrorpr)r)r*�__init__�szFSHookProxy.__init__cCs |jj||jd�}||j|<|S)N)Zremove_plugins)roZsubset_hook_callerrp�__dict__)rq�namerer)r)r*�__getattr__�s
zFSHookProxy.__getattr__N)�__name__�
__module__�__qualname__rrrur)r)r)r*rm�srmc@seZdZdd�Zdd�ZdS)�_CompatPropertycCs
||_dS)N)rt)rqrtr)r)r*rr�sz_CompatProperty.__init__cCs|dkr|Stt|j�S)N)�getattrr2rt)rq�obj�ownerr)r)r*�__get__�sz_CompatProperty.__get__N)rvrwrxrrr}r)r)r)r*ry�sryc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�NodeKeywordscCs||_|j|_|jdi|_dS)NT)�node�parentrt�_markers)rqrr)r)r*rr�szNodeKeywords.__init__cCs8y
|j|Stk
r2|jdkr&�|jj|SXdS)N)r��KeyErrorr��keywords)rq�keyr)r)r*�__getitem__�s

zNodeKeywords.__getitem__cCs||j|<dS)N)r�)rqr�r?r)r)r*�__setitem__�szNodeKeywords.__setitem__cCstd��dS)Nz"cannot delete key in keywords dict)�
ValueError)rqr�r)r)r*�__delitem__�szNodeKeywords.__delitem__cCs*t|j�}|jdk	r"|�|jj�t|�S)N)�setr�r��updater��iter)rq�seenr)r)r*�__iter__�s

zNodeKeywords.__iter__cCst|���S)N)r^r�)rqr)r)r*�__len__�szNodeKeywords.__len__cCst|�S)N)�list)rqr)r)r*�keys�szNodeKeywords.keyscCsd|jfS)Nz<NodeKeywords for node %s>)r)rqr)r)r*�__repr__�szNodeKeywords.__repr__N)rvrwrxrrr�r�r�r�r�r�r�r)r)r)r*r~�sr~c@s�eZdZdZd1dd�Zedd��Zed�Zed�Z	ed	�Z
ed
�Zed�Zed�Z
d
d�Zdd�Zdd�Zedd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd2d/d0�ZeZ dS)3�Nodez~ base class for Collector and Item the test collection tree.
    Collector subclasses have children, Items are terminal nodes.NcCsN||_||_|p|j|_|p |j|_t|dd�|_t|�|_t�|_	i|_
dS)Nrn)rtr�r3r5rzrnr~r�r��extra_keyword_matchesZ_name2pseudofixturedef)rqrtr�r3r5r)r)r*rr�s
z
Node.__init__cCs|j�|j�S)z6 fspath sensitive hook proxy used to call pytest hooks)r5�gethookproxyrn)rqr)r)r*�ihooksz
Node.ihook�Module�Class�Instance�Functionr.r,cCs0tt|�|�}t|t�r"tt|�St||�}|S)N)rzrr>ryr2)rqrtZmaybe_compatprop�clsr)r)r*�_getcustomclasss



zNode._getcustomclasscCsd|jjt|dd�fS)Nz<%s %r>rt)�	__class__rvrz)rqr)r)r*r�+sz
Node.__repr__cCsjt|t�st�t|dd�}|dkr0t|dd�}nd|d|ddf}|jjjt|||j|d�d�dS)	zK generate a warning with the given code and message for this
        item. �locationNrnz%s:%srr)�code�message�nodeid�
fslocation)�kwargs)	r>r$�AssertionErrorrzr�Zpytest_logwarningZ
call_historicr0r�)rqr�r�r�r)r)r*�warn/s
z	Node.warncCs.y|jStk
r(|��|_}|SXdS)z= a ::-separated string denoting its collection tree address. N)Z_nodeid�AttributeError�_makeid)rqrer)r)r*r�>s
zNode.nodeidcCs|jjd|jS)Nz::)r�r�rt)rqr)r)r*r�GszNode._makeidcCs
t|j�S)N)�hashr�)rqr)r)r*�__hash__Jsz
Node.__hash__cCsdS)Nr))rqr)r)r*�setupMsz
Node.setupcCsdS)Nr))rqr)r)r*�teardownPsz
Node.teardowncCs�d|}t||d�}|dk	r8tj�|d|d|d�t||�rLt||�Sy
|�}Wn:tjjk
rp�Yn"t��}t|||��YnXt|||�|S)NZ_ex_rrr)	rzrb�builtinZ_reraise�hasattrZ_sysexrB�exc_info�setattr)rq�attrname�functionZ
exattrnameZfailure�resr)r)r*�
_memoizedcallSs 


zNode._memoizedcallcCs2g}|}x|dk	r$|�|�|j}q
W|��|S)ze return list of all parent collectors up to self,
            starting from root of collection tree. N)rr��reverse)rq�chainrYr)r)r*�	listchaines


zNode.listchaincCsFddlm}t|tjj�r$||�}nt||�s6td��||j|j<dS)zu dynamically add a marker object to the node.

        ``marker`` can be a string or pytest.mark.* instance.
        r)�
MarkDecoratorz'is not a string or pytest.mark.* MarkerN)	�_pytest.markr�r>rbr�Z_basestringr�r�rt)rq�markerr�r)r)r*�
add_markerps

zNode.add_markercCs<|j�|d�}|dk	r8ddlm}m}t|||f�r8|SdS)zf get a marker object from this node or None if
        the node doesn't have a marker with that name. Nr)�MarkInfor�)r��getr�r�r�r>)rqrt�valr�r�r)r)r*�
get_marker|s
zNode.get_markercCs,t�}|}x|��D]}|�|j�qW|S)z< Return a set of all extra keywords in self and any parents.)r�r�r�r�)rqZextra_keywordsrYr)r)r*�listextrakeywords�s
zNode.listextrakeywordscCsdd�|��D�S)NcSsg|]
}|j�qSr))rt)rdrer)r)r*rf�sz"Node.listnames.<locals>.<listcomp>)r�)rqr)r)r*�	listnames�szNode.listnamescCs|jj�||�dS)z� register a function to be called when this node is finalized.

        This method can only be called when this node is active
        in a setup chain, for example during self.setup().
        N)r5Z_setupstate�addfinalizer)rqZfinr)r)r*r��szNode.addfinalizercCs"|}x|rt||�s|j}qW|S)z] get the next parent node (including ourself)
        which is an instance of the given class)r>r�)rqr��currentr)r)r*�	getparent�s
zNode.getparentcCsdS)Nr))rqr6r)r)r*�_prunetraceback�szNode._prunetracebackcCs�|jj}|�|j�r|j��Sd}|jjjr2d}nBt	j
�|jdg�}|�
|�t|j�dkrd||_d}|dkrtd}|dkr�|jjjdkr�d}nd}yt��d}Wntk
r�d}YnX|jd||jjj||d�S)	NT�long���rF�auto�short)Zfuncargs�abspath�
showlocals�style�tbfilter)r5Z_fixturemanagerrKZFixtureLookupErrorr?Z
formatreprr3rIZ	fulltracer<r=�	Traceback�	tracebackr�r^Ztbstyle�os�getcwd�OSErrorZgetreprr�)rqr6r�Zfmr��tbr�r)r)r*�_repr_failure_py�s2



zNode._repr_failure_py)NNN)N)!rvrwrx�__doc__rr�propertyr�ryr�r�r�r�r.r,r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��repr_failurer)r)r)r*r��s8
		
 r�c@s@eZdZdZGdd�de�Zdd�Zdd�Zdd	�Zd
d�Z	dS)
r-zf Collector instances create children through collect()
        and thus iteratively build a tree.
    c@seZdZdZdS)zCollector.CollectErrorz8 an error during collection, contains a custom message. N)rvrwrxr�r)r)r)r*�CollectError�sr�cCstd��dS)za returns a list of children (items and collectors)
            for this collection node.
        ZabstractN)�NotImplementedError)rqr)r)r*r�szCollector.collectcCs.|�|j�r |j}t|jd�S|j|dd�S)z! represent a collection failure. rr�)r�)rKr�r?r$rr�)rqr6�excr)r)r*r��szCollector.repr_failurecs��d�fdd��S)z? internal helper method to cache results of calling collect(). Z
_collectedcst����S)N)r�rr))rqr)r*�<lambda>��z(Collector._memocollect.<locals>.<lambda>)r�)rqr))rqr*�_memocollect�szCollector._memocollectcCs@t|d�r<|j}|j|jd�}||kr2|jtd�}|��|_dS)Nrn)r)Zexcludepath)r�r�Zcutrn�tracebackcutdir�filter)rqr6r�Z
ntracebackr)r)r*r��s
zCollector._prunetracebackN)
rvrwrxr�rAr�rr�r�r�r)r)r)r*r-�sr-cs&eZdZd�fdd�	Zdd�Z�ZS)�FSCollectorNcs\tj�|�}|j}|dk	r<|�|j�}|r.|}|�tjd�}t	t
|��||||�||_dS)N�/)rbrrc�basename�reltorn�replacer��sep�superr�rr)rqrnr�r3r5rt�rel)r�r)r*rr�szFSCollector.__init__cCs,|j�|jj�}tjdkr(|�tjd�}|S)Nr�)rnr�r3�rootdirr�r�r�)rq�relpathr)r)r*r��s
zFSCollector._makeid)NNN)rvrwrxrrr��
__classcell__r)r))r�r*r��sr�c@seZdZdZdS)r.z. base class for collecting tests from a file. N)rvrwrxr�r)r)r)r*r.�sr.csBeZdZdZdZd�fdd�	Zdd�Zdd�Zed	d
��Z	�Z
S)r,zv a basic test invocation item. Note that for a single function
    there might be multiple test invocation items.
    Ncs tt|��||||�g|_dS)N)r�r,rr�_report_sections)rqrtr�r3r5)r�r)r*rrsz
Item.__init__cCs|r|j�|||f�dS)N)r�r)rqZwhenr��contentr)r)r*�add_report_sectionszItem.add_report_sectioncCs|jddfS)N�)rn)rqr)r)r*�
reportinfo	szItem.reportinfocCs�y|jStk
r�|��}|jj�di�}y||d}Wn2tk
rp|jj�	|d�}|||d<YnX||dt
|d�f}||_|SXdS)NZ_bestrelpathcacherrr)Z	_locationr�r�r3rs�
setdefaultr�r5rnZbestrelpathr$)rqr��cachernr)r)r*r�sz
Item.location)NNN)rvrwrxr�rZrrr�r�r�r�r�r)r))r�r*r,�sr,c@seZdZdZdS)�NoMatchz4 raised if matching cannot locate a matching names. N)rvrwrxr�r)r)r)r*r�sr�c@seZdZdZdZdS)r[z" signals an interrupted test run. �builtinsN)rvrwrxr�r)r)r)r*r[ sr[c@s�eZdZeZdd�Zdd�Zejdd�dd��Zejdd�d	d
��Z	e	Z
dd�Zd
d�Zd&dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)'r/cCsftj||jd||d�d|_d|_d|_|jj�d�|_|�	d�|_
tj�
�|_|jjj|dd�dS)N)r�r3r5rFrrr5)rt)r�rrr�rTrVr_�trace�rootr�Zgetini�_norecursepatternsrbrrcrMr3ri�register)rqr3r)r)r*rr's
zSession.__init__cCsdS)Nr�r))rqr)r)r*r�2szSession._makeidT)ZtryfirstcCs|jr|�|j��dS)N)r_r[)rqr)r)r*�pytest_collectstart5szSession.pytest_collectstartcCsH|jrDt|d�sD|jd7_|j�d�}|rD|j|krDd|j|_dS)NZwasxfailrrzstopping after %d failures)�failedr�rTr3�getvaluer_)rq�reportrr)r)r*�pytest_runtest_logreport:sz Session.pytest_runtest_logreportcCs
||jkS)N)�
_initialpaths)rqrr)r)r*�
isinitpathDszSession.isinitpathcCs<|jj}|�|�}|j�|�}|r0t|||�}n|jj}|S)N)r3riZ_getconftestmodulesZ_conftest_plugins�
differencermr9)rqrnroZmy_conftestmodulesrp�proxyr)r)r*r�Gs
zSession.gethookproxyNc	CsH|jj}z"|�||�}|j||j|d�Wd|j|d�Xt|�|_|S)N)r5r3r])r5)r3r9�_perform_collectZpytest_collection_modifyitemsZpytest_collection_finishr^rV)rqr�genitemsr9r]r)r)r*rXUs
zSession.perform_collectcCs6|dkr|jj}|�d||�|jjjd7_g|_t�|_g|_g|_	}x2|D]*}|�
|�}|j�|�|j�|d�qTWt
|�}|jj|d�|jjjd8_|jr�g}x6|jD],\}}d||jdf}	|�d||	f�q�Wtj|��|�s|jS|j�r.x"|jD]}
|j	�|�|
���qW|SdS)NrXrr)r�z(no name %r in any of %r)znot found: %s
%s)r3rr�r��indent�	_notfoundr�r��
_initialpartsr]�	_parseargrrjrr��pytest_collectreportr2r:�result�passedrhr)rqrrr]�arg�parts�rep�errorsr��linerr)r)r*r�`s6



zSession._perform_collectc	cs�x�|jD]�}d�tt|��}|�d|�|jjjd7_yx|�|�D]
}|VqHWWn,tk
r�|j	�
|t��df�YnX|jjjd8_qWdS)Nz::zprocessing argumentr)
r�join�mapr$r�r�r�_collectr�rrrBr�)rqr	rrer)r)r*rszSession.collectccs�|�|�}|�d�}|jdd�rp|r2td|f��xn|jdd�|jddd�D]}x|�|�D]
}|Vq\WqLWn2|jdd	�s�t�x |�|�|�|�D]
}|Vq�WdS)
Nrr)r zinvalid arg %rcSs|jdd�S)Nr)r)�check)rer)r)r*r��r�z"Session._collect.<locals>.<lambda>T)ZfilZrecZbf�sort)r)r�poprr��visit�_recurse�_collectfile�
matchnodes)rqr�namesrrer)r)r*r�s

zSession._collectcCs6|�|�}|�|�s(|j||jd�r(dS|j||d�S)N)rr3r))rr�)r�r�rlr3Zpytest_collect_file)rqrr�r)r)r*r�s


zSession._collectfilecCs^|�|���}|j||jd�r"dSx|jD]}|j|d�r*dSq*W|�|�}|j||d�dS)N)rr3)�fnmatchF)rr�T)r�rgrlr3r�rZpytest_collect_directory)rqrr��patr)r)r*r�s
zSession._recursecCs�ddl}y|�|�}Wntk
r*|SX|dkr8|Sy|�|�}Wn$tk
rj|j|dj}YnX|�|�r�tj	�
|�}|S)z/Convert a dotted module name to path.

        rN)�pkgutil�find_loader�ImportError�get_filenamer��modules�co_filename�
is_packager�r�dirname)rqrer�loaderrr)r)r*�_tryconvertpyarg�s
zSession._tryconvertpyargcCs�t|��d�}|jjjr*|�|d�|d<|d�dtj�}|jj	j
|dd�}|��s�|jjjrtt�
d|d��nt�
d|��||d<|S)	z> return (fspath, names) tuple after checking the file exists. z::rr�T)�abszfile or package not found: z (missing __init__.py?)zfile not found: )r$�splitr3rIZpyargsr#r�r�r�Zinvocation_dirr
rr2r:)rqrr	r�rr)r)r*r�s

zSession._parseargcCsr|�d||�|jjjd7_|�||�}t|�}|�d|d�|jjjd8_|dkrnt||dd���|S)Nrrzmatchnodes finished -> �nodesr)r�r�r�_matchnodesr^r�)rq�matchingrr&rr)r)r*r�szSession.matchnodesc
Cs|r|s|S|d}|st�|dd�}g}x�|D]�}t|tj�rR|s2|�|�q2t|tj�sbt�t|�}|jr�d}xD|jD]:}	|	j	|ks�|	j	�
d�d|kr||�|�|	g|��d}q|W|s�t
|j�dkr�|	j	dkr�|�d|�|�|�|	g|��|jj|d�q2W|S)NrrF�[Tz())r�)r�r>r2r,rr-rrrrtr%rhrr^�insertr�r)
rqr(rrtZ	nextnamesZresultnodesrr
Zhas_matchedrer)r)r*r'�s0

zSession._matchnodesccs�|�d|�t|tj�r.|jj|d�|VnVt|tj�s>t�t|�}|j	rvx(|j
D]}x|�|�D]
}|VqdWqTW|jj|d�dS)Nr)rY)r�)
r�r>r2r,r�Zpytest_itemcollectedr-r�rrrrr)rqrr
Zsubnoderer)r)r*r�szSession.genitems)NT)rvrwrxr[rrr�r2Zhookimplr�r�rr�r�rXr�rrrrr#rrr'rr)r)r)r*r/$s&
r/)4r�r%r�rBr<Z
_pytest._coderbr2�collectionsrZMappingMixinr�UserDictrZ_pytest.configrZ_pytest.runnerrrrc�__file__rgr�r8rUrHrJZEXIT_USAGEERRORrWr+r1r4rOrQrPrRrSrlrm�objectryr~r�r-r�r.r,rAr�r;r[r/r)r)r)r*�<module>sR2'$P!"