
    tfT                     v    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dS )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     Y/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/test/test_stan.pyprotor      s     3w<<!b!!!    c                   r    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dS )TagTestsz
    Tests for L{Tag}.
    r   Nc                     t          d          }|                     |j        d           |                     |j        i            dS )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   sJ    
 <(((\222,,,,,r   c                     |                      t                    5 }t          d           ddd           n# 1 swxY w Y   |                     |j        j        d         d           dS )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&   s    
 y)) 	Q	 	 	 	 	 	 	 	 	 	 	 	 	 	 	KQ!S	
 	
 	
 	
 	
s   8<<c                 v    t                      }|                     ||                    d                     dS )z0
        L{Tag.fillSlots} returns self.
        test)r'   N)r   assertIdentical	fillSlotsr   s     r   test_fillSlotszTagTests.test_fillSlots1   s7     ggS#--V-"<"<=====r   c                 J   dg}t          d|dd          }|                    d           d|_        d	|_        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   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   s    "N	M9GOTTT%    		u	%%)'2G<<< 0#.AAA-)CDDD===U^A.	:::u~666en===333)1---+R00077777r   c                    t          d          }dg}t          d||d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/   r0   r1   r2   r4   r5   r6   r   r8      Nr9   )r   innerTagrA   r   r=   s        r   test_cloneDeepzTagTests.test_cloneDeepQ   s    >>!N	8Ygo
 
 
 	%    		)'2G<<< 0#.AAA===S\!_h777q 18<<<S\!_i888q 19===u~666en===333)1---+R00077777r   c                     t          d t          d          D                       }|                     t          dt          j        t          j                 j        |j	                   dS )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   4   K   | ]}t          |          V  d S N)str).0ns     r   	<genexpr>z:TagTests.test_cloneGeneratorDeprecation.<locals>.<genexpr>y   s(      ..qCFF......r   
   zCloning 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   sf     ..E"II.....) K'0I	
 	
 	
 	
 	
r   c                 0   dt           fd} |            }t          d|d          }	 |                     t          dt          j        t          j                 j        |j	                   |
                                 dS # |
                                 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           rJ   )NotImplementedError r   r   	asyncFuncz:TagTests.test_cloneCoroutineDeprecation.<locals>.asyncFunc   s      %%r   123789zCloning 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   s    	& 	& 	& 	& 	& y{{E4''	"- CN+4	   JJLLLLLDJJLLLLs   AA? ?Bc                     t          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?   coolzthis-attribute)andSoIsrd   N)r   clearr   r?   r   r   s     r   
test_clearzTagTests.test_clear   sd    
 KV=MNNN		r***)5E)FGGGGGr   c                     t          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.
        divr
   )class_classN)r	   r   r   )r   r   r   s      r   test_suffixzTagTests.test_suffix   sK    
 E

egg3'388888r   c                 f    |                      t          t          d                    d           dS )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   s1    
 	gm44557OPPPPPr   c                 f    |                      t          t          d                    d           dS )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   s1    
 	eK00113GHHHHHr   c                     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   rm   r   )r   snowmans     r   test_charrefReprzTagTests.test_charrefRepr   s=    
 m$$gg..//AAAAAr   )r   N)__name__rU   __qualname____doc__r   r%   r*   rB   rG   rW   ra   rf   rk   ro   rq   ru   r[   r   r   r   r      s!        - - - -	
 	
 	
 	
> > > >8 8 8 82 8  8  8  8D
 
 
 
"   2H H H H9 9 9 9Q Q Q QI I I IB B B B B Br   r   )rx   rS   typingr   twisted.trial.unittestr   twisted.web.templater   r   r   r   r	   r   r   r[   r   r   <module>r|      s     


       + + + + + + J J J J J J J J J J J J J J"k " " " " " "mB mB mB mB mBx mB mB mB mB mBr   