Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/_pytest/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyo

�
�mYc@`sdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
e	jddkr�ddlmZneZeZeZdejjfd��YZd"Zd#d$d%d&fZgeD]=\ZZee	jkr�ed�ee�ee�f^q�ZgeD]Z ee �^qCeZej!ed�ed�j"e��Z#[[[ej!d�Z$d�Z%de&fd��YZ'ej(d��Z)d�Z*d�Z+d�Z,d�Z-d e&fd!��YZ.dS('s'
    report test results in JUnit-XML format,
    for use with Jenkins and build integration servers.


Based on initial code from Ross Lawley.

Output conforms to https://github.com/jenkinsci/xunit-plugin/blob/master/
src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
i(tabsolute_importtdivisiontprint_functionN(tfilename_argi(topentJunitcB`seZRS((t__name__t
__module__(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyRsi	i
i
i i~i�i��i�i��ii��s%s-%ss[^%s]ts\.py$cC`s1d�}tjjtj|tjj|���S(NcS`s>t|j��}|dkr,td�|Std�|SdS(Ni�s#x%02Xs#x%04X(tordtgrouptunicode(tmatchobjti((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytrepl:s(tpytxmltrawtillegal_xml_retsubtescape(targR((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytbin_xml_escape9s	t
_NodeReportercB`s�eZd�Zd�Zd�Zd�Zd�Zd�Zdd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�ZRS(cC`sR||_||_|jj|_d|_g|_g|_d|_i|_dS(Ni(	tidRt	add_statstdurationt
propertiestnodestNonettestcasetattrs(tselftnodeidR((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyt__init__Es						cC`s-|jjt|�j�|jj|�dS(N(RRttypeRRtappend(R tnode((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR$PscC`s&|jjt|�t|�f�dS(N(RR$tstrR(R tnametvalue((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytadd_propertyTscC`sH|jrDtjg|jD]$\}}tjd|d|�^q�SdS(sBReturn a Junit node containing custom properties, if any.
        R'R(R(RRtproperty(R R'R(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytmake_properties_nodeWs
	2cC`s�t|j�}|d }|jjr>|jd|jj�nidj|�d6t|d�d6|jdd6}|jddk	r�|jd|d<nt	|d	�r�|j
|d	<n||_dS(
Ni����it.t	classnameR'tfileitlineturl(tmangle_test_addressR!RtprefixtinserttjoinRtlocationRthasattrR0R(R t
testreporttnamest
classnamesR((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytrecord_testreportas
cC`sStjd|j|j�}|j|j��x|jD]}|j|�q8W|S(Nttime(RRRRR$R+R(R RR%((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytto_xmlrs
cC`s/t|�}||d|�}|j|�dS(Ntmessage(RR$(R tkindR=tdataR%((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyt_add_simpleyscC`s]xVdD]N}t|d|�}|rttd|�}|j|t|���qqWdS(Ntoutterrtcapstdssystem-(RARB(tgetattrRR$R(R treporttcapnametcontentttag((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytwrite_captured_output~s

cC`s|jd�dS(Ntpassed(R(R RE((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_pass�scC`s�t|d�r%|jtjd�n�t|jd�rI|jjj}n3t|jtt	f�rm|j}nt	|j�}t
|�}tjd|�}|jt
|j��|j|�dS(Ntwasxfails%xfail-marked test passes unexpectedlyt	reprcrashR=(
R6R@RtskippedtlongreprRMR=t
isinstanceRR&RtfailureR$(R RER=tfail((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_failure�s
cC`s)|jtjt|j�dd��dS(NR=scollection failure(R$RterrorRRO(R RE((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_collect_error�scC`s|jtjd|j�dS(Nscollection skipped(R@RRNRO(R RE((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_collect_skipped�scC`sDt|dd�dkr!d}nd}|jtj||j�dS(Ntwhentteardownstest teardown failurestest setup failure(RDRR@RRTRO(R REtmsg((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_error�s
	cC`s�t|d�r+|jtjd|j�nc|j\}}}|jd�r_t|d�}n|jtjd|||fddd|��|j	|�dS(	NRLsexpected test failures	Skipped: i	s	%s:%s: %sR#spytest.skipR=(
R6R@RRNRLROt
startswithRR$RI(R REtfilenametlinenot
skipreason((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytappend_skipped�s
c`s;|j�jdd��|jj��fd�|_dS(Ntindentic`stjj��S(N(RRR((R?(sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyt<lambda>�R(R<Rt__dict__tclear(R ((R?sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytfinalize�s
N(RRR"R$R)R+R:R<RR@RIRKRSRURVRZR_Rd(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyRDs				
									cC`sg|jjdddd�t|jdd�}|dk	rV|j|jj�}|jSd�}|SdS(s�Add extra xml properties to the tag for the calling test.
    The fixture is callable with ``(name, value)``, with value being automatically
    xml-encoded.
    tcodetC3R=s.record_xml_property is an experimental featuret_xmlcS`sdS(N((R'R(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytadd_property_noop�sN(R%twarnRDtconfigRt
node_reporterR!R)(trequestRRkRh((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytrecord_xml_property�s	cC`s�|jd�}|jdddddddd	d
tjtdd�ddd
d�|jddddddddd
d�|jdddd�dS(Nsterminal reportings
--junitxmls--junit-xmltactiontstoretdesttxmlpathtmetavartpathR#toptnametdefaultthelps1create junit-xml style report file at given path.s
--junitprefixs--junit-prefixR&s0prepend prefix to classnames in junit-xml outputtjunit_suite_names Test suite name for JUnit reporttpytest(tgetgroupt	addoptiont	functoolstpartialRRtaddini(tparserR
((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_addoption�s 		cC`s`|jj}|r\t|d�r\t||jj|jd��|_|jj|j�ndS(Nt
slaveinputRw(	toptionRqR6tLogXMLtjunitprefixtgetiniRgt
pluginmanagertregister(RjRq((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_configure�s$cC`s5t|dd�}|r1|`|jj|�ndS(NRg(RDRRgR�t
unregister(RjR((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_unconfigure�scC`s�|jd�\}}}|jd�}y|jd�Wntk
rKnX|djdd�|d<tjd|d�|d<|dc||7<|S(	Nt[s::s()it/R,Ri����(t	partitiontsplittremovet
ValueErrortreplacet
_py_ext_reR(taddressRstpossible_open_brackettparamsR8((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR1�s
R�cB`s�eZdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZRS(RxcC`s�tjjtjj|��}tjjtjj|��|_||_||_t	j
ddddgd�|_i|_g|_
g|_g|_d|_dS(NRTRJRQRNi(tosRst
expandusert
expandvarstnormpathtabspathtlogfileR2t
suite_nametdicttfromkeyststatstnode_reporterstnode_reporters_orderedtglobal_propertiestopen_reportstcnt_double_fail_tests(R R�R2R�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR"s!						cC`sYt|d|�}t|dd�}|jj||f�}|dk	rU|j�ndS(NR!R%(RDRR�tpopRd(R RER!t	slavenodetreporter((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyRds
cC`szt|d|�}t|dd�}||f}||jkrJ|j|St||�}||j|<|jj|�|S(NR!R%(RDRR�RR�R$(R RER!R�tkeyR�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyRk!s
cC`s)||jkr%|j|cd7<ndS(Ni(R�(R R�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR3scC`s |j|�}|j|�|S(N(RkR:(R RER�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyt
_opentestcase7s
c`s�d}�jr@�jdkrB|j��}|j��qBn�jr�jdkr�t�dd��t�dd��t���fd�|jD�d�}|r�|j	|�|j
d7_
q�n|j��}�jdkr
|j��|jj��qB|j
��n(�jrB|j��}|j��n|j���jdkr�|j��}|j��|j	��t�dd��t�dd��t���fd�|jD�d�}|r�|jj|�q�ndS(	shandle a setup/call/teardown report, generating the appropriate
        xml tags as necessary.

        note: due to plugins like xdist, this hook may be called in interlaced
        order with reports from other nodes. for example:

        usual call order:
            -> setup node1
            -> call node1
            -> teardown node1
            -> setup node2
            -> call node2
            -> teardown node2

        possible call order in xdist:
            -> setup node1
            -> call node1
            -> setup node2
            -> call node2
            -> teardown node2
            -> teardown node1
        tcallRXt	worker_idt
item_indexc3`sW|]M}|j�jkrt|dd��krt|dd��kr|VqdS(R�R�N(R!RDR(t.0trep(REt	report_iit
report_wid(sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pys	<genexpr>^sic3`sW|]M}|j�jkrt|dd��krt|dd��kr|VqdS(R�R�N(R!RDR(R�R�(RER�R�(sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pys	<genexpr>{sN(RRJRWR�RKtfailedRDtnextR�RdR�RSR$RZRNR_tupdate_testcase_durationRIR�(R REtclose_reportR�((RER�R�sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_runtest_logreport<sF			

	


	cC`s.|j|�}|jt|dd�7_dS(s�accumulates total duration for nodeid from given report and updates
        the Junit.testcase with the new total if already created.
        RgN(RkRRD(R RER�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR��scC`sE|jsA|j|�}|jr1|j|�qA|j|�ndS(N(RJR�R�RURV(R RER�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_collectreport�s
		cC`sB|jd�}|jjdddd�|jtjd|�dS(NtinternalR-RxR'sinternal error(RkRtupdateR@RRT(R texcreprR�((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_internalerror�scC`stj�|_dS(N(R;tsuite_start_time(R ((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_sessionstart�scC`sKtjjtjj|j��}tjj|�sCtj|�nt|jddd�}tj�}||j	}|j
d|j
d|j
d|j
d|j}|jd�|jt
j|j�g|jD]}|j�^q�d	|jd
|j
dd|j
dd|j
dd
|dd|�jdd��|j�dS(Ntwtencodingsutf-8RJRQRNRTs&<?xml version="1.0" encoding="utf-8"?>R'terrorstfailurestskipsttestsR;s%.3fR`i(R�RstdirnameR�R�tisdirtmakedirsRR;R�R�R�twriteRt	testsuitet_get_global_properties_nodeR�R<R�Rtclose(R R�R�tsuite_stop_timetsuite_time_deltatnumteststx((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_sessionfinish�s&!
+

	"	


cC`s|jdd|j�dS(Nt-sgenerated xml file: %s(t	write_sepR�(R tterminalreporter((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytpytest_terminal_summary�s	cC`s&|jjt|�t|�f�dS(N(R�R$R&R(R R'R(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pytadd_global_property�scC`sH|jrDtjg|jD]$\}}tjd|d|�^q�SdS(sBReturn a Junit node containing custom properties, if any.
        R'R(R(R�RRR*(R R'R(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR��s
	2(RRR"RdRkRR�R�R�R�R�R�R�R�R�R�(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyR�s					H							(i	i
i
(i i~(i�i��(i�i��(ii��(/t__doc__t
__future__RRRR{RR�tretsysR;Rxt_pytest.configRtversion_infotcodecsRtchrtunichrR&RtinttlongRt	NamespaceRt_legal_charst
_legal_rangestlowthight
maxunicodet
_legal_xml_reR�tcompileR4RR�RtobjectRtfixtureRmRR�R�R1R�(((sA/opt/alt/python27/lib/python2.7/site-packages/_pytest/junitxml.pyt<module>
sB	G#(	|