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__/junitxml.cpython-39.pyc
a

05dtd�@s�dZddlZddlZddlZddlZddlmmZddl	m	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddlZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%e#d�Z&e'e(d�dd�Z)dd�dd�Z*iZ+dddgie+d <dgd!�ie+d"<e+d �,�e+d#<e*e+d#e+d"�e+d e+d$<Gd%d&�d&�Z-ee(dd'�d(d)�Z.ej/eee(e'gdfd*�d+d,��Z0ej/eee(e'gdfd*�d-d.��Z1e(e(dd/�d0d1�Z2ej/d2d3�eee(e'gdfd*�d4d5��Z3edd6�d7d8�Z4edd9�d:d;�Z5edd9�d<d=�Z6e(e
e(d>�d?d@�Z7GdAd�d�Z8dS)BaReport 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
�N)�datetime)�Callable)�Dict)�List)�Match)�Optional)�Tuple)�Union)�nodes)�timing)�
ExceptionRepr)�ReprFileLocation)�Config)�filename_arg)�Parser)�FixtureRequest)�
TestReport)�StashKey)�TerminalReporter�LogXML)�arg�returncCs*tttd�dd�}d}t�||t|��S)a!Visually escape invalid XML characters.

    For example, transforms
        'hello\aworld\b'
    into
        'hello#x07world#x08'
    Note that the #xABs are *not* XML escapes - missing the ampersand &#xAB.
    The idea is to escape visually for the user rather than for XML itself.
    )�matchobjrcSs(t|���}|dkrd|Sd|SdS)N�z#x%02Xz#x%04X)�ord�group)r�i�r�4/usr/lib/python3.9/site-packages/_pytest/junitxml.py�repl3szbin_xml_escape.<locals>.replu [^	

 -~€-퟿-�က0-ჿFF])r�str�re�sub)rrZillegal_xml_rerrr�bin_xml_escape(s�r#�rcCsXi}|��D]<\}}|��D]*\}}t|t�s:tt|���||||<qq|�|�dS�N)�items�
isinstance�list�	TypeError�type�update)�left�right�result�klZvlZkrZvrrrr�merge_familyCs
r0�testcase�	classname�nameZ_base)�file�line�urlZ_base_legacy�xunit1�xunit2c@sNeZdZeeefddd�dd�Zejdd�dd�Z	ee
dd	�d
d�Zee
dd	�dd
�Ze
ejd�dd�Zedd�dd�Zejd�dd�Zd0eee
edd�dd�Zedd�dd�Zeeed�dd�Zeeedd�d d!�Zedd�d"d#�Zedd�d$d%�Zedd�d&d'�Zedd�d(d)�Zedd�d*d+�Zedd�d,d-�Zdd�d.d/�ZdS)1�
_NodeReporterrN)�nodeid�xmlrcCs<||_||_|jj|_|jj|_d|_g|_g|_i|_dS)N�)�idr;�	add_stats�family�duration�
propertiesr
�attrs)�selfr:r;rrr�__init__Zs

z_NodeReporter.__init__)�nodercCs|j�|j�|j�|�dSr%)r;r>�tagr
�append)rCrErrrrGdsz_NodeReporter.append�r3�valuercCs|j�t|�t|�f�dSr%)rArGr r#�rCr3rIrrr�add_propertyhsz_NodeReporter.add_propertycCst|�|jt|�<dSr%)r#rBr rJrrr�
add_attributeksz_NodeReporter.add_attributer$cCs>|jr:t�d�}|jD]\}}|�tjd||d��q|SdS�z9Return a Junit node containing custom properties, if any.rA�property�r3rIN)rA�ET�ElementrG�rCrAr3rIrrr�make_properties_nodens
z"_NodeReporter.make_properties_node)�
testreportrcCs�t|j�}|j}|dd�}|jjr4|�d|jj�d�|�t|d�|jdd�}|jddurtt	|jd�|d<t
|d�r�|j|d<||_|j�|�|j
dkr�dSi}|j��D]$}|t|j
d	vr�|j|||<q�||_dS)
N���r�.)r2r3r4�r5r6r7r1)�mangle_test_addressr:rBr;�prefix�insert�joinr#�locationr �hasattrr6r+r?�keys�families)rCrT�namesZexisting_attrsZ
classnamesrBZ
temp_attrs�keyrrr�record_testreportws,

�


z_NodeReporter.record_testreportcCsBtjd|jd|jd�}|��}|dur2|�|�|�|j�|S)Nr1�%.3f)�time)rPrQrBr@rSrG�extendr
)rCr1rArrr�to_xml�s
z_NodeReporter.to_xml)rF�message�datarcCs&tj||d�}t|�|_|�|�dS)N)rg�rPrQr#�textrG)rCrFrgrhrErrr�_add_simple�s
z_NodeReporter._add_simple��reportrcCs�|jjs|jrdS|j}|j}|j}|jjdkr4dSd}|jjdvrP|�|d�}|jjdvr~||�|d�7}|�||d�d}|jjdvr�||�|d	�7}|�||d
�d}|r�|�||d�dS)N�no�)�log�allz Captured Log )�
system-out�out-errrqz Captured Out rr)�
system-errrsrqz Captured Err rt)	r;�log_passing_tests�passedZ	capstdoutZcaplogZ	capstderr�logging�_prepare_content�_write_content)rCrmZcontent_outZcontent_logZcontent_errZcontent_allrrr�write_captured_output�s(z#_NodeReporter.write_captured_output)�content�headerrcCsd�|�dd�|dg�S)N�
�P�-ro)r[�center)rCr{r|rrrrx�sz_NodeReporter._prepare_content)rmr{�jheaderrcCs"t�|�}t|�|_|�|�dSr%ri)rCrmr{r�rFrrrry�s

z_NodeReporter._write_contentcCs|�d�dS)Nrv)r>�rCrmrrr�append_pass�sz_NodeReporter.append_passcCsnt|d�r|�dd�nR|jdus&J�t|jdd�}|durD|j}n
t|j�}t|�}|�d|t|j��dS)N�wasxfail�skippedz%xfail-marked test passes unexpectedly�	reprcrash�failure)r]rk�longrepr�getattrrgr r#)rCrmr�rgrrr�append_failure�s
�
z_NodeReporter.append_failurecCs&|jdusJ�|�ddt|j��dS)N�errorzcollection failure)r�rkr r�rrr�append_collect_error�sz"_NodeReporter.append_collect_errorcCs|�ddt|j��dS)Nr�zcollection skipped)rkr r�r�rrr�append_collect_skipped�sz$_NodeReporter.append_collect_skippedcCsv|jdusJ�t|jdd�}|dur,|j}n
t|j�}|jdkrNd|�d�}nd|�d�}|�dt|�t|j��dS)Nr��teardownzfailed on teardown with "�"zfailed on setup with "r�)r�r�rgr �whenrkr#)rCrmr��reason�msgrrr�append_error�s�

z_NodeReporter.append_errorcCs�t|d�rJ|j}|�d�r&|dd�}t|�}tjdd|d�}|�|�ntt|jt	�sZJ�|j\}}}|�d�r||dd�}|�d	|�d
|��}tjdd|d�}t|�|_
|�|�|�|�dS)Nr�zreason: �r�zpytest.xfail)r*rgz	Skipped: �	�:z: zpytest.skip)r]r��
startswithr#rPrQrGr'r��tuplerjrz)rCrmZxfailreasonr��filename�linenoZ
skipreasonZdetailsrrr�append_skipped�s 




z_NodeReporter.append_skippedcs$|���|j���fdd�|_dS)Ncs�Sr%rr�rhrr�<lambda>�z(_NodeReporter.finalize.<locals>.<lambda>)rf�__dict__�clear�rCrr�r�finalizes
z_NodeReporter.finalize)N)�__name__�
__module__�__qualname__r	r rrDrPrQrG�objectrKrLrrSrbrfrkrzrxryr�r�r�r�r�r�r�rrrrr9Ys$
	r9)�request�fixture_namercCsNddlm}|jj�td�}|durJ|jdvrJ|j�|dj	||jd���dS)z[Emit a PytestWarning about the given fixture being incompatible with newer xunit revisions.r)�
PytestWarningN)r7�legacyzV{fixture_name} is incompatible with junit_family '{family}' (use 'legacy' or 'xunit1'))r�r?)
�_pytest.warning_typesr��config�stash�get�xml_keyr?rE�warn�format)r�r�r�r;rrr�!_warn_incompatibility_with_xunit2s���r�)r�rcs$t�d�ttdd��fdd�}|S)anAdd extra properties to the calling test.

    User properties become part of the test report and are available to the
    configured reporters, like JUnit XML.

    The fixture is callable with ``name, value``. The value is automatically
    XML-encoded.

    Example::

        def test_function(record_property):
            record_property("example_key", 1)
    �record_propertyNrHcs�jj�||f�dSr%)rE�user_propertiesrGrO�r�rr�append_property*sz(record_property.<locals>.append_property)r�r r�)r�r�rr�rr�s
r�cCslddlm}|j�|d��t|d�ttdd�dd�}|}|jj�	t
d�}|durh|�|jj�}|j
}|S)	z�Add extra xml attributes to the tag for the calling test.

    The fixture is callable with ``name, value``. The value is
    automatically XML-encoded.
    r)�PytestExperimentalApiWarningz/record_xml_attribute is an experimental feature�record_xml_attributeNrHcSsdSr%rrOrrr�
add_attr_noop@sz+record_xml_attribute.<locals>.add_attr_noop)r�r�rEr�r�r r�r�r�r�r��
node_reporterr:rL)r�r�r�Z	attr_funcr;r�rrrr�0s�
r�)�param�vrcCs.d}t|t�s*d}t|j|t|�jd���dS)zcUsed by record_testsuite_property to check that the given parameter name is of the proper
    type.Tz5{param} parameter needs to be a string, but {g} given)r��gN)r'r r)r�r*r�)r�r��__tracebackhide__r�rrr�_check_record_param_typeMs
r�Zsession)ZscopecCs8d}ttdd�dd�}|jj�td�}|dur4|j}|S)a+Record a new ``<property>`` tag as child of the root ``<testsuite>``.

    This is suitable to writing global information regarding the entire test
    suite, and is compatible with ``xunit2`` JUnit family.

    This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:

    .. code-block:: python

        def test_foo(record_testsuite_property):
            record_testsuite_property("ARCH", "PPC")
            record_testsuite_property("STORAGE_TYPE", "CEPH")

    :param name:
        The property name.
    :param value:
        The property value. Will be converted to a string.

    .. warning::

        Currently this fixture **does not work** with the
        `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
        :issue:`7767` for details.
    TNrHcSsd}td|�dS)zENo-op function in case --junitxml was not passed in the command-line.Tr3N)r�)r3rIr�rrr�record_funcssz.record_testsuite_property.<locals>.record_func)r r�r�r�r�r��add_global_property)r�r�r�r;rrr�record_testsuite_propertyVsr�)�parserrc
Cs�|�d�}|jdddddtjtdd�ddd	�|jd
ddddd
d�|jdddd�|jdddd�|jddddd�|jdddd�|jddd d�dS)!Nzterminal reportingz
--junitxmlz--junit-xml�store�xmlpath�path)Zoptnamez0Create junit-xml style report file at given path)�action�dest�metavarr*�default�helpz
--junitprefixz--junit-prefixr z0Prepend prefix to classnames in junit-xml output)r�r�r�r��junit_suite_namez Test suite name for JUnit report�pytest)r��
junit_loggingz\Write captured log messages to JUnit report: one of no|log|system-out|system-err|out-err|allrn�junit_log_passing_testsz;Capture log information for passing tests to JUnit report: �boolT)r*r��junit_duration_reportz*Duration time to report: one of total|call�total�junit_familyz0Emit XML for schema: one of legacy|xunit1|xunit2r8)ZgetgroupZ	addoption�	functools�partialrZaddini)r�rrrr�pytest_addoption~sV
�
������r�)r�rc
Csl|jj}|rht|d�sh|�d�}t||jj|�d�|�d�|�d�||�d��|jt<|j�	|jt�dS)NZworkerinputr�r�r�r�r�)
�optionr�r]ZgetinirZjunitprefixr�r��
pluginmanager�register)r�r�r�rrr�pytest_configure�s
�
	r�cCs*|j�td�}|r&|jt=|j�|�dSr%)r�r�r�r�Z
unregister)r�r;rrr�pytest_unconfigure�sr�)�addressrcCs^|�d�\}}}|�d�}|d�tjd�|d<t�dd|d�|d<|d||7<|S)N�[z::rrVz\.py$rorU)�	partition�split�replacer
ZSEPr!r")r�r�Zpossible_open_bracket�paramsr`rrrrX�s
rXc@seZdZd*eeeeeedd�dd	�Zedd
�dd�Ze	eefe
d
�d
d�Zedd�dd�Zee
d
�dd�Z
edd
�dd�Zedd
�dd�Zedd
�dd�Zedd�dd�Zdd�dd�Zdd�d d!�Zedd"�d#d$�Zeedd%�d&d'�Zeejd�d(d)�ZdS)+rr�rnr�r7TN)rY�
suite_namerw�report_durationrurcCs�tj�tj�|��}tj�tj�|��|_||_||_||_	||_
||_||_t
�gd�d�|_i|_g|_g|_g|_d|_|jdkr�d|_dS)N)r�rvr�r�rr�r7)�osr��
expanduser�
expandvars�normpath�abspath�logfilerYr�rwrur�r?�dict�fromkeys�stats�node_reporters�node_reporters_ordered�global_properties�open_reports�cnt_double_fail_tests)rCr�rYr�rwr�r?rurrrrD�s&
��
zLogXML.__init__rlcCs<t|d|�}t|dd�}|j�||f�}|dur8|��dS�Nr:rE)r�r��popr�)rCrmr:�
workernode�reporterrrrr��s
zLogXML.finalizecCsXt|d|�}t|dd�}||f}||jvr4|j|St||�}||j|<|j�|�|Sr�)r�r�r9r�rG)rCrmr:r�rar�rrrr��s



zLogXML.node_reporter)rarcCs ||jvr|j|d7<dS)NrW)r�)rCrarrrr>s
zLogXML.add_statscCs|�|�}|�|�|Sr%)r�rb�rCrmr�rrr�
_opentestcases

zLogXML._opentestcasecs�d}�jr*�jdkr�|���}|���nĈjrԈjdkr�t�dd��t�dd��t���fdd�|jD�d�}|r�|�|�|j	d7_	|���}�jdkr�|�
��|j���|js�|�
��q�|���n�jr�|���}|���|����jdk�r�|���}|�
���jD]\}}|�|t|���q|���t�dd��t�dd��t���fd	d�|jD�d�}|�r�|j�|�dS)
aHandle 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
        N�callr��	worker_id�
item_indexc3s>|]6}|j�jkrt|dd��krt|dd��kr|VqdS�r�Nr��r:r���.0Zrep�rmZ	report_iiZ
report_widrr�	<genexpr>9s
�z2LogXML.pytest_runtest_logreport.<locals>.<genexpr>rWc3s>|]6}|j�jkrt|dd��krt|dd��kr|VqdSr�r�r�r�rrras
�)rvr�r�r��failedr��nextr�r�r�r�rGrurzr�r�r��update_testcase_durationr�rKr �remove)rCrmZclose_reportr�ZpropnameZ	propvaluerr�r�pytest_runtest_logreportsZ


�	�









�	�zLogXML.pytest_runtest_logreportcCs:|jdks|j|jkr6|�|�}|jt|dd�7_dS)z�Accumulate total duration for nodeid from given report and update
        the Junit.testcase with the new total if already created.r�r@r<N)r�r�r�r@r�r�rrrros
zLogXML.update_testcase_durationcCs0|js,|�|�}|jr"|�|�n
|�|�dSr%)rvr�rr�r�r�rrr�pytest_collectreportvs

zLogXML.pytest_collectreport)�excreprrcCs0|�d�}|jjddd�|�ddt|��dS)NZinternalr�)r2r3r�zinternal error)r�rBr+rkr )rCrr�rrr�pytest_internalerror~s
zLogXML.pytest_internalerrorr$cCst��|_dSr%)rrd�suite_start_timer�rrr�pytest_sessionstart�szLogXML.pytest_sessionstartc
CsVtj�tj�|j��}tj|dd�t|jddd���
}t��}||j	}|j
d|j
d|j
d|j
d	|j}|�d
�t
jd|jt|j
d	�t|j
d�t|j
d�t|�d|t�|j	���t��d
�	}|��}|dur�|�|�|jD]}|�|���q�t
�d�}	|	�|�|�t
j|	dd��Wd�n1�sH0YdS)NT)�exist_ok�wzutf-8)�encodingrvr�r�r�z&<?xml version="1.0" encoding="utf-8"?>Z	testsuiterc)r3�errorsZfailuresr�ZtestsrdZ	timestamp�hostname�
testsuitesZunicode)r�r��dirnamer�r��makedirs�openrrdr	r�r��writerPrQr�r rZ
fromtimestampZ	isoformat�platformrE�_get_global_properties_noderGr�rfZtostring)
rCrr�Zsuite_stop_timeZsuite_time_deltaZnumtestsZ
suite_noder�r�rrrr�pytest_sessionfinish�sF
�����
�



zLogXML.pytest_sessionfinish)�terminalreporterrcCs|�dd|j���dS)Nrzgenerated xml file: )Z	write_sepr�)rCrrrr�pytest_terminal_summary�szLogXML.pytest_terminal_summaryrHcCs&d}td|�|j�|t|�f�dS)NTr3)r�r�rGr#)rCr3rIr�rrrr��s
zLogXML.add_global_propertycCs>|jr:t�d�}|jD]\}}|�tjd||d��q|SdSrM)r�rPrQrGrRrrrr�s
z"LogXML._get_global_properties_node)r�rnr�r7T)r�r�r�rr r�rDrr�r	r9r�r>r�rrrrrr
rrrr�r�rPrQrrrrrr�s4��#X&)9�__doc__r�r�rr!Zxml.etree.ElementTreeZetreeZElementTreerPr�typingrrrrrrr	r�Z_pytestr
rZ_pytest._code.coderr
Z_pytest.configrrZ_pytest.config.argparsingrZ_pytest.fixturesrZ_pytest.reportsrZ
_pytest.stashrZ_pytest.terminalrr�r�r r#r0r_�copyr9r�Zfixturer�r�r�r�r�r�r�rXrrrrr�<module>sf

1�	
'/

Youez - 2016 - github.com/yon3zu
LinuXploit