403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.15.238.90
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/xunit.cpython-37.pyc
B

0�Se}-�@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
m
Z
ddlmZddl
mZddlmZddlmZmZe�d	�Ze�d
�Zdd�Zd
d�Zdd�Zdd�Zdd�ZGdd�de�ZGdd�de�ZdS)aUThis plugin provides test results in the standard XUnit XML format.

It's designed for the `Jenkins`_ (previously Hudson) continuous build
system, but will probably work for anything else that understands an
XUnit-formatted XML representation of test results.

Add this shell command to your builder ::

    nosetests --with-xunit

And by default a file named nosetests.xml will be written to the
working directory.

In a Jenkins builder, tick the box named "Publish JUnit test result report"
under the Post-build Actions and enter this value for Test report XMLs::

    **/nosetests.xml

If you need to change the name or location of the file, you can set the
``--xunit-file`` option.

If you need to change the name of the test suite, you can set the
``--xunit-testsuite-name`` option.

Here is an abbreviated version of what an XML test report might look like::

    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite name="nosetests" tests="1" errors="1" failures="0" skip="0">
        <testcase classname="path_to_test_suite.TestSomething"
                  name="test_it" time="0">
            <error type="exceptions.TypeError" message="oops, wrong type">
            Traceback (most recent call last):
            ...
            TypeError: oops, wrong type
            </error>
        </testcase>
    </testsuite>

.. _Jenkins: http://jenkins-ci.org/

�N)�StringIO)�time)�saxutils)�Plugin)�SkipTest)�
force_unicode�format_exceptionz[\000-\010\013\014\016-\037]z^(.*?)(\(.*\))$cCst�d|�S)z)Replaces invalid XML characters with '?'.�?)�CONTROL_CHARACTERS�sub)�value�r
�C/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/xunit.py�xml_safe>srcCst|��dd�S)z)Escape a string for an XML CDATA section.z]]>z]]>]]&gt;<![CDATA[)r�replace)Zcdatar
r
r�escape_cdataBsrcCsFt�|�}|r6|��\}}|�dd�\}}|||gS|�dd�SdS)N�.�)�TEST_ID�match�groups�rsplit)Zidval�m�nameZfargs�head�tailr
r
r�id_splitFs
rcCs\t�|�r|j}n|jj}t�|�}|rT|j}|�d�rH|td�d�}d||fS|SdS)z�Returns a nice name for class object or class instance.

        >>> nice_classname(Exception()) # doctest: +ELLIPSIS
        '...Exception'
        >>> nice_classname(Exception) # doctest: +ELLIPSIS
        '...Exception'

    zorg.python.core.Nz%s.%s)�inspect�isclass�__name__�	__class__�	getmodule�
startswith�len)�objZcls_name�modrr
r
r�nice_classnameOs	


r&cCsz|d}|dkr|d}nNyt|�}Wn@tk
rfyt|�}Wntk
r`|jd}YnXYnXt|d�}t|�S)zReturn the exception's message.rNrzUTF-8)�str�UnicodeEncodeError�UnicodeError�argsrr)�exc_info�exc�resultr
r
r�exc_messagefs

r.c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TeecGs||_||_dS)N)�	_encoding�_streams)�self�encodingr*r
r
r�__init__zszTee.__init__cCs*t||j�}x|jD]}|�|�qWdS)N)rr0r1�write)r2�data�sr
r
rr5~sz	Tee.writecCsx|D]}|�|�qWdS)N)r5)r2�lines�liner
r
r�
writelines�s
zTee.writelinescCsx|jD]}|��qWdS)N)r1�flush)r2r7r
r
rr;�sz	Tee.flushcCsdS)NFr
)r2r
r
r�isatty�sz
Tee.isattyN)r�
__module__�__qualname__r4r5r:r;r<r
r
r
rr/ys
r/cs�eZdZdZdZdZdZdZ�fdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd*d$d%�Zd+d&d'�Zd,d(d)�Z�ZS)-�XunitzCThis plugin provides test results in the standard XUnit XML format.Zxuniti�zUTF-8Ncs$tt|���g|_d|_d|_dS)N)�superr?r4�_capture_stack�_currentStdout�_currentStderr)r2)r r
rr4�szXunit.__init__cCs t|d�rt�|j}nd}|S)N�_timerg)�hasattrrrD)r2�takenr
r
r�
_timeTaken�s
zXunit._timeTakencCst|�}t�|�S)z.Escape an XML attribute. Value can be unicode.)rrZ	quoteattr)r2�attrr
r
r�
_quoteattr�szXunit._quoteattrc	CsNt�|||�|jdddd|�dd�dd�|jd	dd
d|�dd
�dd�dS)z%Sets additional command line options.z--xunit-file�store�
xunit_fileZFILEZNOSE_XUNIT_FILEz
nosetests.xmlzrPath to xml file to store the xunit report in. Default is nosetests.xml in the working directory [NOSE_XUNIT_FILE])�action�dest�metavar�default�helpz--xunit-testsuite-name�xunit_testsuite_nameZPACKAGEZNOSE_XUNIT_TESTSUITE_NAMEZ	nosetestszbName of the testsuite in the xunit xml, generated by plugin. Default test suite name is nosetests.N)r�options�
add_option�get)r2�parser�envr
r
rrR�s

z
Xunit.optionscCsLt�|||�||_|jrHddddd�|_g|_tj�|j	�|_
|j|_dS)zConfigures the xunit plugin.r)�errors�failures�passes�skippedN)r�	configure�config�enabled�stats�	errorlist�os�path�realpathrK�error_report_file_namerQ)r2rRr\r
r
rr[�s
zXunit.configurecs�t��jd�jd��_�j�jd<�j�jd<�jd�jd�jd�jd�jd	<�j�d
�j��j�d��fdd
��j	D����j�d��j�
��jjdkr�|�
d�|�
d�jj�dS)zmWrites an Xunit-formatted XML file

        The file includes a report of test errors and failures.

        �wrr3Ztestsuite_namerWrXrYrZ�totalz�<?xml version="1.0" encoding="%(encoding)s"?><testsuite name="%(testsuite_name)s" tests="%(total)d" errors="%(errors)d" failures="%(failures)d" skip="%(skipped)d">�csg|]}t|�j��qSr
)rr3)�.0�e)r2r
r�
<listcomp>�sz Xunit.report.<locals>.<listcomp>z</testsuite>rzF----------------------------------------------------------------------zXML: %sN)�codecs�openrcr3�error_report_filer^rQr5�joinr_�closer\�	verbosity�writelnr)r2�streamr
)r2r�report�s
.


zXunit.reportcCsP|j�tjtjf�t�|_t�|_t|j	|jtj�t_t|j	|jtj�t_dS)N)
rA�append�sys�stdout�stderrrrBrCr/r3)r2r
r
r�
_startCapture�s
zXunit._startCapturecCs|��dS)N)rw)r2�contextr
r
r�startContext�szXunit.startContextcCs|��dS)N)�_endCapture)r2rxr
r
r�stopContext�szXunit.stopContextcCst�|_|��dS)z+Initializes a timer before starting a test.N)rrDrw)r2�testr
r
r�
beforeTest�szXunit.beforeTestcCs|jr|j��\t_t_dS)N)rA�poprtrurv)r2r
r
rrz�szXunit._endCapturecCs|��d|_d|_dS)N)rzrBrC)r2r|r
r
r�	afterTest�szXunit.afterTestcCsx|jr|��qWdS)N)rArz)r2r|r
r
r�finalize�szXunit.finalizecCs$|jr |j��}|r dt|�SdS)Nz'<system-out><![CDATA[%s]]></system-out>rf)rB�getvaluer)r2rr
r
r�_getCapturedStdouts
zXunit._getCapturedStdoutcCs$|jr |j��}|r dt|�SdS)Nz'<system-err><![CDATA[%s]]></system-err>rf)rCr�r)r2rr
r
r�_getCapturedStderrs
zXunit._getCapturedStderrc
Cs�|��}t|dt�r.d}|jdd7<nd}|jdd7<t||j�}|��}|j�d|�	t
|�d�|�	t
|�d�|||�	t|d��|�	t|��t
|�|��|��d�	�d	S)
z*Add error output to Xunit report.
        rrZr�errorrWz�<testcase classname=%(cls)s name=%(name)s time="%(taken).3f"><%(type)s type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]></%(type)s>%(systemout)s%(systemerr)s</testcase>���)	�clsrrF�type�errtype�message�tb�	systemout�	systemerrN)rG�
issubclassrr^rr3�idr_rsrIrr&r.rr�r�)r2r|�err�captrFr�r�r�r
r
r�addErrors&zXunit.addErrorcCs�|��}t||j�}|jdd7<|��}|j�d|�t|�d�|�t|�d�||�t	|d��|�t
|��t|�|��|�
�d��dS)z,Add failure output to Xunit report.
        rXrz�<testcase classname=%(cls)s name=%(name)s time="%(taken).3f"><failure type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]></failure>%(systemout)s%(systemerr)s</testcase>rr�)r�rrFr�r�r�r�r�N)rGrr3r^r�r_rsrIrr&r.rr�r�)r2r|r�r�Ztb_inforFr�r�r
r
r�
addFailure1szXunit.addFailurec	Csf|��}|jdd7<|��}|j�d|�t|�d�|�t|�d�||��|��d��dS)z,Add success output to Xunit report.
        rYrzb<testcase classname=%(cls)s name=%(name)s time="%(taken).3f">%(systemout)s%(systemerr)s</testcase>rr�)r�rrFr�r�N)	rGr^r�r_rsrIrr�r�)r2r|r�rFr�r
r
r�
addSuccessGszXunit.addSuccess)N)NN)N)rr=r>�__doc__r�scorer3rlr4rGrIrRr[rrrwryr{r}rzrr�r�r�r�r�r��
__classcell__r
r
)r rr?�s.


r?)r�rj�doctestr`rt�	traceback�rer�iorrZxml.saxrZnose.plugins.baserZnose.excrZnose.pyversionrr�compiler
rrrrr&r.�objectr/r?r
r
r
r�<module>)s,

	

Youez - 2016 - github.com/yon3zu
LinuXploit