U
    
W[#  ć                   @   s`   d Z ddlmZmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZ dd ZG dd	 d	e
Zd
S )zW
Tests for L{twisted.web._stan} portion of the L{twisted.web.template}
implementation.
é    )Śabsolute_importŚdivision)ŚCommentŚCDATAŚCharRefŚTag)ŚTestCase)Ś_PY3c                  O   s   t d| |S )z(
    Produce a new tag for testing.
    Śhello)r   )ŚaŚkw© r   ś</usr/lib/python3/dist-packages/twisted/web/test/test_stan.pyŚproto   s    r   c                   @   s~   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zesfde_de_nde	_de
_dd ZdS )ŚTagTestsz
    Tests for L{Tag}.
    c                 C   s   t  }|  ||jdd” dS )z0
        L{Tag.fillSlots} returns self.
        Śtest)r   N)r   ŚassertIdenticalŚ	fillSlots©ŚselfŚtagr   r   r   Śtest_fillSlots   s    zTagTests.test_fillSlotsc                 C   sņ   dg}t d|ddd}|jdd d|_d	|_d
|_|jdd}|  |jd d” |  |j|j” |  |j	d|g” |  |j	|j	” |  
|j	d |” |  |j|j” |  |j|j” |  |jd” |  |jd	” |  |jd
” |  |jd” dS )z“
        L{Tag.clone} copies all attributes and children of a tag, including its
        render attribute.  If the shallow flag is C{False}, that's where it
        stops.
        ś
inner listśHow are youŚworldŚaSampleMethod©r
   ŚrenderŚbar©Zfoośfoo/baré   é   F)Zdeepr
   é   N©r   r   ŚfilenameZ
lineNumberZcolumnNumberŚcloneŚassertEqualŚ
attributesZassertNotIdenticalŚchildrenr   ZslotDatar   )r   Ś	innerListr   r&   r   r   r   Śtest_cloneShallow"   s*     ’zTagTests.test_cloneShallowc                 C   s  t d}dg}t d||ddd}|jdd d	|_d
|_d|_| ” }|  |jd d” |  |j|j” |  |j	|j	” |  
|j	d |” |  |j	d |” |  
|j	d |” |  |j	d |” |  |j|j” |  |j|j” |  |jd	” |  |jd
” |  |jd” |  |jd” dS )zų
        L{Tag.clone} copies all attributes and children of a tag, including its
        render attribute.  In its normal operating mode (where the deep flag is
        C{True}, as is the default), it will clone all sub-lists and sub-tags.
        Śinnerr   r   r   r   r   r   r   r    r!   r"   r
   r#   é   Nr$   )r   ZinnerTagr*   r   r&   r   r   r   Śtest_cloneDeep=   s0     ’zTagTests.test_cloneDeepc                 C   s<   t ddddd}| ”  |  |jg ” |  |jddi” dS )zk
        L{Tag.clear} removes all children from a tag, but leaves its attributes
        in place.
        z	these arer)   Zcoolzthis-attribute)ŚandSoIsr/   N)r   Śclearr'   r)   r(   r   r   r   r   Ś
test_clear_   s    zTagTests.test_clearc                 C   s.   t d}| }|dd |  |jddi” dS )z
        L{Tag.__call__} accepts Python keywords with a suffixed underscore as
        the DOM attribute of that literal suffix.
        Zdivr   )Zclass_ŚclassN)r   r'   r(   )r   r   r   r   r   r   Śtest_suffixj   s    
zTagTests.test_suffixc                 C   s   |   ttdd” dS )śo
        L{Comment.__repr__} returns a value which makes it easy to see what's
        in the comment.
        śhello therezComment(u'hello there')N©r'   Śreprr   ©r   r   r   r   Śtest_commentReprPy2u   s    ’zTagTests.test_commentReprPy2c                 C   s   |   ttdd” dS )śm
        L{CDATA.__repr__} returns a value which makes it easy to see what's in
        the comment.
        ś	test datazCDATA(u'test data')N©r'   r7   r   r8   r   r   r   Śtest_cdataReprPy2~   s    ’zTagTests.test_cdataReprPy2c                 C   s   |   ttdd” dS )r4   r5   zComment('hello there')Nr6   r8   r   r   r   Śtest_commentReprPy3   s    ’zTagTests.test_commentReprPy3c                 C   s   |   ttdd” dS )r:   r;   zCDATA('test data')Nr<   r8   r   r   r   Śtest_cdataReprPy3   s    ’zTagTests.test_cdataReprPy3zOnly relevant on Python 3.zOnly relevant on Python 2.c                 C   s    t d}|  tt|d” dS )zw
        L{CharRef.__repr__} returns a value which makes it easy to see what
        character is referred to.
        u   āzCharRef(9731)N)Śordr'   r7   r   )r   Zsnowmanr   r   r   Śtest_charrefRepr    s    zTagTests.test_charrefReprN)Ś__name__Ś
__module__Ś__qualname__Ś__doc__r   r+   r.   r1   r3   r9   r=   r>   r?   r	   ŚskiprA   r   r   r   r   r      s    "			r   N)rE   Z
__future__r   r   Ztwisted.web.templater   r   r   r   Ztwisted.trial.unittestr   Ztwisted.python.compatr	   r   r   r   r   r   r   Ś<module>   s   