Your IP : 216.73.216.196


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

B

�A^k�@s�ddlZddlZddlZddlZddlmZdZdZdZej	dkr^de
d�e
eej	d��fZe�d	eej
�jZddd�ZGd
d�de�ZGdd�de�ZdS)�N)�Document)�TestXMLBuilder�TestXMLContextzUTF-8�iz%s-%si��z)[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD%s]��cCs
t||�S)N)�_nontext_sub)�textZreplacement�r	�B/opt/alt/python37/lib/python3.7/site-packages/xmlrunner/builder.py�replace_nontext!src@sVeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)ra�A XML report file have a distinct hierarchy. The outermost element is
    'testsuites', which contains one or more 'testsuite' elements. The role of
    these elements is to give the proper context to 'testcase' elements.

    These contexts have a few things in common: they all have some sort of
    counters (i.e. how many testcases are inside that context, how many failed,
    and so on), they all have a 'time' attribute indicating how long it took
    for their testcases to run, etc.

    The purpose of this class is to abstract the job of composing this
    hierarchy while keeping track of counters and how long it took for a
    context to be processed.
    )Ztests�errorsZfailures�skippedNcCs"||_||_d|_|_i|_dS)z|Creates a new instance of a root or nested context (depending whether
        `parent_context` is provided or not).
        rN)�xml_doc�parent�_start_time�
_stop_time�counters)�selfrZparent_contextr	r	r
�__init__7szTestXMLContext.__init__cCs|jjS)zAReturns the name of the tag represented by this context.
        )�elementZtagName)rr	r	r
�element_tag@szTestXMLContext.element_tagcCs.|j�|�|_|j�dt|��t��|_dS)zuBegins the creation of this context in the XML document by creating
        an empty tag <tag name='param'>.
        �nameN)r�
createElementr�setAttributer�timer)r�tagrr	r	r
�beginEszTestXMLContext.begincCs<t��|_|j�d|���|j�d|���|��|jS)z�Closes this context (started with a call to `begin`) and creates an
        attribute for each counter and another for the elapsed time.
        r�	timestamp)rrrr�elapsed_timer�_set_result_counters)rr	r	r
�endMs

zTestXMLContext.endcCs^|��}xPtjD]F}d}|dkr*|dk}n|dk}|rt|j�|d��}|j�||�qWdS)zuSets an attribute in this context's tag for each counter considering
        what's valid for each tag name.
        Fr
�	testsuite)Z
testsuitesr!rN)rr�_allowed_counters�strr�getrr)rr�counter_nameZvalid_counter_for_element�valuer	r	r
rWs
z#TestXMLContext._set_result_counterscCs&|tjkr"|j�|d�d|j|<dS)zsIncrements a counter named by `counter_name`, which can be any one
        defined in `_allowed_counters`.
        r�N)rr"rr$)rr%r	r	r
�increment_counteros
z TestXMLContext.increment_countercCst|j|jd�S)zqReturns the time the context took to run between the calls to
        `begin()` and `end()`, in seconds.
        z.3f)�formatrr)rr	r	r
rwszTestXMLContext.elapsed_timecCstj�|j�jdd���S)zLReturns the time the context ended as ISO-8601-formatted timestamp.
        r)Zmicrosecond)�datetimeZ
fromtimestampr�replaceZ	isoformat)rr	r	r
r}szTestXMLContext.timestamp)N)
�__name__�
__module__�__qualname__�__doc__r"rrrr rr(rrr	r	r	r
r%s

	
rc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)rziThis class encapsulates most rules needed to create a XML test report
    behind a simple interface.
    cCst�|_d|_dS)z Creates a new instance.
        N)r�_xml_doc�_current_context)rr	r	r
r�szTestXMLBuilder.__init__cCs|jS)z%Returns the current context.
        )r1)rr	r	r
�current_context�szTestXMLBuilder.current_contextcCs$t|j|j�}|�||�||_dS)z�Begins a new context in the XML test report, which usually is defined
        by one on the tags 'testsuites', 'testsuite', or 'testcase'.
        N)rr0r1r)rrr�contextr	r	r
�
begin_context�szTestXMLBuilder.begin_contextcCs
|j��S)z<Returns the tag represented by the current context.
        )r1r)rr	r	r
�context_tag�szTestXMLBuilder.context_tagcCst|�}|j�|�S)zXReturns a new CDATA section containing the string defined in
        `content`.
        )rr0ZcreateCDATASection)r�contentZfiltered_contentr	r	r
�_create_cdata_section�sz$TestXMLBuilder._create_cdata_sectioncCs||j�|�}|�d�}xF|dkr\|d|d�}|�|�|��||dd�}|�d�}qW|�|�|��|�|�|S)z�Appends a tag in the format <tag>CDATA</tag> into the tag represented
        by the current context. Returns the created tag.
        z]]>r�N)r0r�find�appendChildr7�
_append_child)rrr6r�posZtmpr	r	r
�append_cdata_section�s


z#TestXMLBuilder.append_cdata_sectioncKs\|j�|�}x,|��D] \}}tt|��}|�||�qW|rN|�|�|��|�|�|S)z�Apends a tag in the format <tag attr='val' attr2='val2'>CDATA</tag>
        into the tag represented by the current context. Returns the created
        tag.
        )	r0r�itemsrr#rr:r7r;)rrr6�kwargsr�keyr&Zfiltered_valuer	r	r
�append�s
zTestXMLBuilder.appendcCs&|jr|jj�|�n|j�|�dS)zoAppends a tag object represented by `element` into the tag
        represented by the current context.
        N)r1rr:r0)rrr	r	r
r;�szTestXMLBuilder._append_childcCs$|j}x|r|�|�|j}qWdS)zGIncrements a counter in the current context and their parents.
        N)r1r(r)rr%r3r	r	r
r(�s
z TestXMLBuilder.increment_countercCs,|js
dS|j��}|jj|_|�|�dS)z�Ends the current context and sets the current context as being the
        previous one (if it exists). Also, when a context ends, its tag is
        appended in the proper place inside the document.
        FT)r1r rr;)rrr	r	r
�end_context�s


zTestXMLBuilder.end_contextcCsx|��rqW|jjdtd�S)zkEnds all open contexts and returns a pretty printed version of the
        generated XML document.
        �	)�indent�encoding)rBr0Ztoprettyxml�UTF8)rr	r	r
�finish�s
zTestXMLBuilder.finishN)r,r-r.r/rr2r4r5r7r=rAr;r(rBrGr	r	r	r
r�s			r)r)�re�sysr*rZxml.dom.minidomr�__all__rFZ
_char_tail�
maxunicode�chr�min�compile�U�subrr�objectrrr	r	r	r
�<module>s"


^