Ë
    ojT  ã                   ón   — d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	m
Z
mZ de
de
defd	„Z G d
„ de«      Zy)zW
Tests for L{twisted.web._stan} portion of the L{twisted.web.template}
implementation.
é    N)ÚNoReturn)ÚTestCase)ÚCDATAÚCharRefÚCommentÚFlattenableÚTagÚaÚkwÚreturnc                  ó$   —  t        d«      | i |¤ŽS )z(
    Produce a new tag for testing.
    Úhello)r	   )r
   r   s     ú</usr/lib/python3/dist-packages/twisted/web/test/test_stan.pyÚprotor      s   € ð Œ3ˆw‹<˜Ð!˜bÑ!Ð!ó    c                   óp   — 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dd„Zdd„Zdd„Zy)ÚTagTestsz
    Tests for L{Tag}.
    Nc                 óŒ   — t        d¬«      }| j                  |j                  d«       | j                  |j                  i «       y)zŠ
        Setting an attribute named C{render} will change the C{render} instance
        variable instead of adding an attribute.
        Ú
myRenderer©ÚrenderN)r   ÚassertEqualr   Ú
attributes©ÚselfÚtags     r   Útest_renderAttributezTagTests.test_renderAttribute   s6   € ô
 ˜<Ô(ˆØ×Ñ˜Ÿ™ \Ô2Ø×Ñ˜Ÿ™¨Õ,r   c                 óÂ   — | j                  t        «      5 }t        d¬«       ddd«       | j                  j                  j
                  d   d«       y# 1 sw Y   Œ3xY w)z‚
        Attempting to set an attribute named C{render} to something other than
        a string will raise L{TypeError}.
        éS   r   Nr   z0Value for "render" attribute must be str, got 83)ÚassertRaisesÚ	TypeErrorr   r   Ú	exceptionÚargs)r   Úes     r   Útest_renderAttributeNonStringz&TagTests.test_renderAttributeNonString&   sT   € ð
 ×ÑœyÓ)ð 	¨QÜ˜Õ÷	à×ÑØ�K‰K×Ñ˜QÑÐ!Sõ	
÷	ð 	ús   –AÁAc                 ó\   — t        «       }| j                  ||j                  d¬«      «       y)z0
        L{Tag.fillSlots} returns self.
        Útest)r'   N)r   ÚassertIdenticalÚ	fillSlotsr   s     r   Útest_fillSlotszTagTests.test_fillSlots1   s&   € ô ‹gˆØ×Ñ˜S #§-¡-°V -Ó"<Õ=r   c                 ób  — dg}t        d|dd¬«      }|j                  d¬«       d|_        d	|_        d
|_        |j                  d¬«      }| j                  |j                  d   d«       | j                  |j                  |j                  «       | j                  |j                  d|g«       | j                  |j                  |j                  «       | j                  |j                  d   |«       | j                  |j                  |j                  «       | j                  |j                  |j                  «       | j                  |j                  d«       | j                  |j                  d	«       | j                  |j                  d
«       | j                  |j                  d«       y)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   r   Úbar©Úfooúfoo/baré   é   F)Údeepr   é   N©r   r)   ÚfilenameÚ
lineNumberÚcolumnNumberÚcloner   r   ÚassertNotIdenticalÚchildrenr(   ÚslotDatar   )r   Ú	innerListr   r=   s       r   Útest_cloneShallowzTagTests.test_cloneShallow8   sR  € ð "�Nˆ	Ü�M 9°GÀOÔTˆØ�‰˜%ˆÔ Ø ˆŒØˆŒØˆÔØ—	‘	˜u�	Ó%ˆØ×Ñ˜×)Ñ)¨'Ñ2°GÔ<Ø×Ñ × 0Ñ 0°#·.±.ÔAØ×Ñ˜Ÿ™¨-¸Ð)CÔDØ×Ñ §¡°·±Ô=Ø×Ñ˜UŸ^™^¨AÑ.°	Ô:Ø×Ñ˜Ÿ™ u§~¡~Ô6Ø×Ñ §¡¨e¯n©nÔ=Ø×Ñ˜Ÿ™¨Ô3Ø×Ñ˜×)Ñ)¨1Ô-Ø×Ñ˜×+Ñ+¨RÔ0Ø×Ñ˜Ÿ™ Õ7r   c                 óô  — t        d«      }dg}t        d||dd¬«      }|j                  d¬«       d	|_        d
|_        d|_        |j                  «       }| j                  |j                  d   d«       | j                  |j                  |j                  «       | j                  |j                  |j                  «       | j                  |j                  d   |«       | j                  |j                  d   |«       | j                  |j                  d   |«       | j                  |j                  d   |«       | j                  |j                  |j                  «       | j                  |j                  |j                  «       | j                  |j                  d	«       | j                  |j                  d
«       | j                  |j                  d«       | j                  |j                  d«       y)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/   r0   r1   r2   r4   r5   r6   r   r8   é   Nr9   )r   ÚinnerTagrA   r   r=   s        r   Útest_cloneDeepzTagTests.test_cloneDeepQ   s�  € ô ˜“>ˆØ!�Nˆ	ÜØ˜8 Y°gÀoô
ˆð 	�‰˜%ˆÔ Ø ˆŒØˆŒØˆÔØ—	‘	“ˆØ×Ñ˜×)Ñ)¨'Ñ2°GÔ<Ø×Ñ × 0Ñ 0°#·.±.ÔAØ×Ñ §¡°·±Ô=à×Ñ˜SŸ\™\¨!™_¨hÔ7à×Ñ §¡¨qÑ 1°8Ô<à×Ñ˜SŸ\™\¨!™_¨iÔ8à×Ñ §¡¨qÑ 1°9Ô=Ø×Ñ˜Ÿ™ u§~¡~Ô6Ø×Ñ §¡¨e¯n©nÔ=Ø×Ñ˜Ÿ™¨Ô3Ø×Ñ˜×)Ñ)¨1Ô-Ø×Ñ˜×+Ñ+¨RÔ0Ø×Ñ˜Ÿ™ Õ7r   c                 óÐ   — t        d„ t        d«      D «       «      }| j                  t        dt        j
                  t        j                     j                  |j                  «       y)zì
        Cloning a tag containing a generator is unsafe. To avoid breaking
        programs that only flatten the clone or only flatten the original,
        we deprecate old behavior rather than making it an error immediately.
        c              3   ó2   K  — | ]  }t        |«      –— Œ y ­w©N)Ústr)Ú.0Úns     r   ú	<genexpr>z:TagTests.test_cloneGeneratorDeprecation.<locals>.<genexpr>y   s   è ø€ Ò.˜q”C˜—FÑ.ùs   ‚é
   z´Cloning a Tag which contains a generator is unsafe, since the generator can be consumed only once; this is deprecated since Twisted 21.7.0 and will raise an exception in the futureN)
r   ÚrangeÚassertWarnsÚDeprecationWarningÚsysÚmodulesr	   Ú
__module__Ú__file__r=   r   s     r   Útest_cloneGeneratorDeprecationz'TagTests.test_cloneGeneratorDeprecations   sM   € ô Ñ.¤E¨"£IÔ.Ó.ˆØ×ÑÜð)ô �K‰KœŸ™Ñ'×0Ñ0Ø�I‰Iõ	
r   c                 ó"  — dt         fd„} |«       }t        d|d«      }	 | j                  t        dt        j
                  t        j                     j                  |j                  «       |j                  «        y# |j                  «        w xY w)zì
        Cloning a tag containing a coroutine is unsafe. To avoid breaking
        programs that only flatten the clone or only flatten the original,
        we deprecate old behavior rather than making it an error immediately.
        r   c               “   ó   K  — t         ‚­wrJ   )ÚNotImplementedError© r   r   Ú	asyncFuncz:TagTests.test_cloneCoroutineDeprecation.<locals>.asyncFunc‹   s   è ø€ Ü%Ð%ùs   ‚	Ú123Ú789z¬Cloning a Tag which contains a coroutine is unsafe, since the coroutine can run only once; this is deprecated since Twisted 21.7.0 and will raise an exception in the futureN)r   r   rQ   rR   rS   rT   r	   rU   rV   r=   Úclose)r   r\   Úcoror   s       r   Útest_cloneCoroutineDeprecationz'TagTests.test_cloneCoroutineDeprecation„   st   € ð	&¤ó 	&ñ ‹{ˆÜ�E˜4 Ó'ˆð	Ø×ÑÜ"ð-ô —‘œCŸN™NÑ+×4Ñ4Ø—	‘	ôð �J‰J�LøˆD�J‰J�Lús    AA< Á<Bc                 ó¶   — t        dddd¬«      }|j                  «        | j                  |j                  g «       | j                  |j                  ddi«       y)zk
        L{Tag.clear} removes all children from a tag, but leaves its attributes
        in place.
        z	these arer?   Úcoolzthis-attribute)ÚandSoIsrd   N)r   Úclearr   r?   r   r   s     r   Ú
test_clearzTagTests.test_clear�   sL   € ô
 �K ¨VÐ=MÔNˆØ�	‰	ŒØ×Ñ˜Ÿ™ rÔ*Ø×Ñ˜Ÿ™¨)Ð5EÐ)FÕGr   c                 óv   — t        d«      } |«       } |d¬«       | j                  |j                  ddi«       y)z‰
        L{Tag.__call__} accepts Python keywords with a suffixed underscore as
        the DOM attribute of that literal suffix.
        Údivr
   )Úclass_ÚclassN)r	   r   r   )r   r   r   s      r   Útest_suffixzTagTests.test_suffix§   s3   € ô
 �E“
ˆÙ‹gˆÙ�3�Ø×Ñ˜Ÿ™¨'°3¨Õ8r   c                 óL   — | j                  t        t        d«      «      d«       y)zo
        L{Comment.__repr__} returns a value which makes it easy to see what's
        in the comment.
        zhello therezComment('hello there')N)r   Úreprr   ©r   s    r   Útest_commentReprPy3zTagTests.test_commentReprPy3±   s   € ð
 	×Ñœœg mÓ4Ó5Ð7OÕPr   c                 óL   — | j                  t        t        d«      «      d«       y)zm
        L{CDATA.__repr__} returns a value which makes it easy to see what's in
        the comment.
        z	test datazCDATA('test data')N)r   rm   r   rn   s    r   Útest_cdataReprPy3zTagTests.test_cdataReprPy3¸   s   € ð
 	×Ñœœe KÓ0Ó1Ð3GÕHr   c                 ób   — t        d«      }| j                  t        t        |«      «      d«       y)zw
        L{CharRef.__repr__} returns a value which makes it easy to see what
        character is referred to.
        u   â˜ƒzCharRef(9731)N)Úordr   rm   r   )r   Úsnowmans     r   Útest_charrefReprzTagTests.test_charrefRepr¿   s(   € ô
 �mÓ$ˆØ×Ñœœg gÓ.Ó/°ÕAr   )r   N)Ú__name__rU   Ú__qualname__Ú__doc__r   r%   r*   rB   rG   rW   ra   rf   rk   ro   rq   ru   r[   r   r   r   r      sH   „ ñó-ó	
ó>ó8ó2 8óD
ó"ó2Hó9óQóIôBr   r   )rx   rS   Útypingr   Útwisted.trial.unittestr   Útwisted.web.templater   r   r   r   r	   r   r   r[   r   r   ú<module>r|      sE   ðñó Ý å +ß JÕ Jð"ˆkð " ð "°ó "ômBˆxõ mBr   