§
    Étºf;  ã                   ó|  — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZ ddlmZmZ ddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$  G d„ de
¦  «        Z% G d„ de	¦  «        Z& G d„ de
¦  «        Z' G d„ de
¦  «        Z( G d„ dej)        ¦  «        Z* G d„ de	¦  «        Z+dS )z 
Tests for L{twisted.web.util}.
é    N)Údefer)ÚnetworkString)ÚFailure)ÚSynchronousTestCaseÚTestCase)ÚresourceÚutil)ÚFlattenerError)ÚFOUND)ÚRequest)Ú	TagLoaderÚflattenStringÚtags)ÚDummyChannelÚDummyRequest)	ÚDeferredResourceÚFailureElementÚParentRedirectÚ_FrameElementÚ_SourceFragmentElementÚ_SourceLineElementÚ_StackElementÚformatFailureÚ
redirectToc                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚRedirectToTestsz"
    Tests for L{redirectTo}.
    c                 ól  — t          t          ¦   «         d¦  «        }d|_        d}t          ||¦  «         |                      |j        t          ¦  «         |                      |j                             d¦  «        |g¦  «         |                      |j                             d¦  «        dg¦  «         dS )z¾
        L{redirectTo} will set the C{Location} and C{Content-Type} headers on
        its request, and set the response code to C{FOUND}, so the browser will
        be redirected.
        Tó   GETs   http://target.example.com/4321s   locations   content-types   text/html; charset=utf-8N)	r   r   Úmethodr   ÚassertEqualÚcoder   ÚresponseHeadersÚgetRawHeaders©ÚselfÚrequestÚ	targetURLs      úY/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/test/test_util.pyÚtest_headersAndCodez#RedirectToTests.test_headersAndCode&   s¹   € õ �,™.œ.¨$Ñ/Ô/ˆØˆŒØ5ˆ	Ý�9˜gÑ&Ô&Ð&Ø×Ò˜œ¥uÑ-Ô-Ð-Ø×ÒØÔ#×1Ò1°+Ñ>Ô>ÀÀñ	
ô 	
ð 	
ð 	×ÒØÔ#×1Ò1°/ÑBÔBØ(Ð)ñ	
ô 	
ð 	
ð 	
ð 	
ó    c                 ó”   — t          t          ¦   «         d¦  «        }d|_        d}|                      t          t
          ||¦  «         dS )zW
        L{redirectTo} will raise TypeError if unicode object is passed in URL
        Tr   zhttp://target.example.com/4321N)r   r   r   ÚassertRaisesÚ	TypeErrorr   r$   s      r(   Útest_redirectToUnicodeURLz)RedirectToTests.test_redirectToUnicodeURL9   sC   € õ �,™.œ.¨$Ñ/Ô/ˆØˆŒØ4ˆ	Ø×Ò�)¥Z°¸GÑDÔDÐDÐDÐDr*   c                 óv   — t          dg¦  «        }t          d|¦  «        }d}|                      ||¦  «         dS )zq
        Legitimate URLs are fully interpolated in the `redirectTo` response body without transformation
        r*   s   https://twisted.org/sÚ   
<html>
    <head>
        <meta http-equiv="refresh" content="0;URL=https://twisted.org/">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <a href="https://twisted.org/">click here</a>
    </body>
</html>
N©r   r   r    ©r%   r&   ÚhtmlÚexpecteds       r(   Útest_legitimateRedirectz'RedirectToTests.test_legitimateRedirectB   sH   € õ  ˜uÑ%Ô%ˆÝÐ1°7Ñ;Ô;ˆð	ˆð 	×Ò˜˜xÑ(Ô(Ð(Ð(Ð(r*   c                 óv   — t          dg¦  «        }t          d|¦  «        }d}|                      ||¦  «         dS )zm
        Malicious URLs are HTML-escaped before interpolating them in the `redirectTo` response body
        r*   s?   https://twisted.org/"><script>alert(document.location)</script>sX  
<html>
    <head>
        <meta http-equiv="refresh" content="0;URL=https://twisted.org/&quot;&gt;&lt;script&gt;alert(document.location)&lt;/script&gt;">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <a href="https://twisted.org/&quot;&gt;&lt;script&gt;alert(document.location)&lt;/script&gt;">click here</a>
    </body>
</html>
Nr0   r1   s       r(   Útest_maliciousRedirectz&RedirectToTests.test_maliciousRedirectT   sM   € õ  ˜uÑ%Ô%ˆÝØNÐPWñ
ô 
ˆð	ˆð 	×Ò˜˜xÑ(Ô(Ð(Ð(Ð(r*   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   r.   r4   r6   © r*   r(   r   r   !   s]   € € € € € ðð ð
ð 
ð 
ð&Eð Eð Eð)ð )ð )ð$)ð )ð )ð )ð )r*   r   c                   ó4   — e Zd ZdZdedefd„Zd„ Zd„ Zd„ ZdS )	ÚParentRedirectTestsz!
    Test L{ParentRedirect}.
    ÚrequestPathÚreturnc                 ó&  — t          t          ¦   «         d¦  «        }d|_        |                     d¦  «                             d¦  «        |_        t          ¦   «         } |j        |¦  «         |j         	                    d¦  «        }|€J ‚|\  }|S )zÉ
        Render a response to a request with path *requestPath*

        @param requestPath: A slash-separated path like C{b'/foo/bar'}.

        @returns: The value of the I{Location} header.
        Tr   ó   /s   Location)
r   r   r   ÚlstripÚsplitÚprepathr   Úrenderr"   r#   )r%   r>   r&   r   ÚheadersÚlocations         r(   ÚdoLocationTestz"ParentRedirectTests.doLocationTestn   sŒ   € õ �,™.œ.¨$Ñ/Ô/ˆØˆŒØ%×,Ò,¨TÑ2Ô2×8Ò8¸Ñ>Ô>ˆŒå!Ñ#Ô#ˆØˆŒ˜Ñ Ô Ð àÔ)×7Ò7¸ÑDÔDˆØÐ"Ð"Ð"Ø‰
ˆØˆr*   c                 óª   — |                       d|                      d¦  «        ¦  «         |                       d|                      d¦  «        ¦  «         dS )zi
        At the URL root issue a redirect to the current URL, removing any query
        string.
        ó   http://10.0.0.1/rA   s   /?biff=baffN©r    rH   ©r%   s    r(   Útest_locationRootz%ParentRedirectTests.test_locationRoot‚   sT   € ð
 	×ÒÐ,¨d×.AÒ.AÀ$Ñ.GÔ.GÑHÔHÐHØ×ÒÐ,¨d×.AÒ.AÀ.Ñ.QÔ.QÑRÔRÐRÐRÐRr*   c                 óª   — |                       d|                      d¦  «        ¦  «         |                       d|                      d¦  «        ¦  «         dS )zt
        A request for a resource one level down from the URL root produces
        a redirect to the root.
        rJ   s   /foos   /foo?bar=sproiiingNrK   rL   s    r(   Útest_locationToRootz'ParentRedirectTests.test_locationToRootŠ   s_   € ð
 	×ÒÐ,¨d×.AÒ.AÀ'Ñ.JÔ.JÑKÔKÐKØ×ÒØ ×!4Ò!4Ð5JÑ!KÔ!Kñ	
ô 	
ð 	
ð 	
ð 	
r*   c                 óü   — |                       d|                      d¦  «        ¦  «         |                       d|                      d¦  «        ¦  «         |                       d|                      d¦  «        ¦  «         dS )zp
        Requests for resources directly under the path C{/foo/} produce
        redirects to C{/foo/}.
        s   http://10.0.0.1/foo/s   /foo/s   /foo/bars   /foo/bar?biz=bazNrK   rL   s    r(   Útest_locationUpOnez&ParentRedirectTests.test_locationUpOne”   s„   € ð
 	×ÒÐ0°$×2EÒ2EÀhÑ2OÔ2OÑPÔPÐPØ×ÒÐ0°$×2EÒ2EÀkÑ2RÔ2RÑSÔSÐSØ×ÒØ# T×%8Ò%8Ð9LÑ%MÔ%Mñ	
ô 	
ð 	
ð 	
ð 	
r*   N)	r7   r8   r9   r:   ÚbytesrH   rM   rO   rQ   r;   r*   r(   r=   r=   i   sp   € € € € € ðð ð¨%ð °Eð ð ð ð ð(Sð Sð Sð
ð 
ð 
ð	
ð 	
ð 	
ð 	
ð 	
r*   r=   c                   óT   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ ZdS )ÚFailureElementTestszn
    Tests for L{FailureElement} and related helpers which can render a
    L{Failure} as an HTML string.
    c                 óÄ   — d„ }|j         j        dz   | _        	  |¦   «          dS # t          $ r0 t	          d¬¦  «        | _        | j        j        d         | _        Y dS w xY w)zO
        Create a L{Failure} which can be used by the rendering tests.
        c                  ó$   — d} t          | ¦  «        ‚)NzThis is a problem)Ú	Exception)Úmessages    r(   ÚlineNumberProbeAlsoBrokenz<FailureElementTests.setUp.<locals>.lineNumberProbeAlsoBroken«   s   € Ø)ˆGÝ˜GÑ$Ô$Ð$r*   é   T)ÚcaptureVarséÿÿÿÿN)Ú__code__Úco_firstlinenoÚbaseÚBaseExceptionr   ÚfailureÚframesÚframe)r%   rY   s     r(   ÚsetUpzFailureElementTests.setUp¦   sƒ   € ð
	%ð 	%ð 	%ð
 .Ô6ÔEÈÑIˆŒ	ð	1Ø%Ð%Ñ'Ô'Ð'Ð'Ð'øÝð 	1ð 	1ð 	1Ý"¨tÐ4Ñ4Ô4ˆDŒLØœÔ,¨RÔ0ˆDŒJˆJˆJˆJð	1øøøs   ™
% ¥6AÁAc           
      ó4  — t          t          t          j        t          j        d¬¦  «        t          j        d¬¦  «        ¦  «        ¦  «        dd¦  «        }t          d|¦  «        }d}|                     | j        |                     d¦  «        ¦  «         |S )	zN
        L{_SourceLineElement} renders a source line and line number.
        Ú
lineNumber©rE   Ú
sourceLineé2   z    print 'hello'Nu:   <div><span>50</span><span> Â  Â print 'hello'</span></div>zutf-8)	r   r   r   ÚdivÚspanr   ÚaddCallbackr    Úencode)r%   ÚelementÚdr3   s       r(   Útest_sourceLineElementz*FailureElementTests.test_sourceLineElement¸   s—   € õ %ÝÝ”�œ¨,Ð7Ñ7Ô7½¼È,Ð9WÑ9WÔ9WÑXÔXñô ð Øñ
ô 
ˆõ ˜$ Ñ(Ô(ˆðOð 	ð 	
�Š�dÔ&¨¯ª¸Ñ(@Ô(@ÑAÔAÐAØˆr*   c           
      ó4  — t          t          t          j        t          j        d¬¦  «        t          j        d¬¦  «        d¬¦  «        ¦  «        | j        ¦  «        }g d¢}t          d|¦  «        }d}t          |¦  «        D ]d\  }}d}|d	k    r2||                     dd
g|d	k             | j	        |z   d|z   ¦  «        z  }Œ?||                     d| j	        |z   d|z   ¦  «        z  }Œe| 
                    d¦  «        }|                     | j        |¦  «         |S )zƒ
        L{_SourceFragmentElement} renders source lines at and around the line
        number indicated by a frame object.
        rf   rg   rh   ÚsourceLines)u#    Â  Â message = "This is a problem"u    Â  Â raise Exception(message)Ú Nrs   z?<div class="snippet{}Line"><span>{}</span><span>{}</span></div>rZ   Ú	Highlightu    Â  Â  Â  Â Úutf8)r   r   r   rj   rk   rc   r   Ú	enumerateÚformatr_   rm   rl   r    )	r%   rn   Úsourcero   ÚstringToCheckForrf   rh   ÚtemplateÚbytesToCheckFors	            r(   Útest_sourceFragmentElementz.FailureElementTests.test_sourceFragmentElementË   sT  € õ
 )ÝÝ”Ý”I \Ð2Ñ2Ô2Ý”I \Ð2Ñ2Ô2Ø(ðñ ô ñô ð ŒJñ	
ô 	
ˆð
ð 
ð 
ˆõ
 ˜$ Ñ(Ô(ˆàÐÝ&/°Ñ&7Ô&7ð 	ð 	Ñ"ˆJ˜
ØXˆHØ˜QŠˆØ  H§O¢OØ˜Ð% j°A¢oÔ6Ø”I 
Ñ*Ø.°Ñ;ñ%ô %ñ Ð Ð ð ! H§O¢OØ˜œ	 JÑ.°°j±ñ%ô %ñ Ð Ð ð +×1Ò1°&Ñ9Ô9ˆà	�Š�dÔ&¨Ñ8Ô8Ð8Øˆr*   c           	      ó  — t          t          t          j        d¬¦  «        ¦  «        | j        ¦  «        }t          d|¦  «        }|                     | j        dt          t           
                    d¦  «        ¦  «        z   dz   ¦  «         |S )z­
        The I{filename} renderer of L{_FrameElement} renders the filename
        associated with the frame object used to initialize the
        L{_FrameElement}.
        Úfilenamerg   Nó   <span>Úcó   </span>)r   r   r   rk   rc   r   rl   r    r   Ú__file__Úrstrip©r%   rn   ro   s      r(   Útest_frameElementFilenamez-FailureElementTests.test_frameElementFilenameõ   s   € õ  ¥	­$¬)¸:Ð*FÑ*FÔ*FÑ GÔ GÈÌÑTÔTˆÝ˜$ Ñ(Ô(ˆØ	�Šð ÔØ�¥h§o¢o°cÑ&:Ô&:Ñ;Ô;Ñ;¸jÑHñ		
ô 	
ð 	
ð ˆr*   c                 óÞ   — t          t          t          j        d¬¦  «        ¦  «        | j        ¦  «        }t          d|¦  «        }|                     | j        d| j        dz   fz  ¦  «         |S )z²
        The I{lineNumber} renderer of L{_FrameElement} renders the line number
        associated with the frame object used to initialize the
        L{_FrameElement}.
        rf   rg   Ns   <span>%d</span>rZ   )	r   r   r   rk   rc   r   rl   r    r_   r„   s      r(   Útest_frameElementLineNumberz/FailureElementTests.test_frameElementLineNumber  sd   € õ  ¥	­$¬)¸<Ð*HÑ*HÔ*HÑ IÔ IÈ4Ì:ÑVÔVˆÝ˜$ Ñ(Ô(ˆØ	�Š�dÔ&Ð(:¸d¼iÈ!¹mÐ=MÑ(MÑNÔNÐNØˆr*   c                 óÆ   — t          t          t          j        d¬¦  «        ¦  «        | j        ¦  «        }t          d|¦  «        }|                     | j        d¦  «         |S )z°
        The I{function} renderer of L{_FrameElement} renders the line number
        associated with the frame object used to initialize the
        L{_FrameElement}.
        Úfunctionrg   Ns&   <span>lineNumberProbeAlsoBroken</span>)r   r   r   rk   rc   r   rl   r    r„   s      r(   Útest_frameElementFunctionz-FailureElementTests.test_frameElementFunction  sV   € õ  ¥	­$¬)¸:Ð*FÑ*FÔ*FÑ GÔ GÈÌÑTÔTˆÝ˜$ Ñ(Ô(ˆØ	�Š�dÔ&Ð(QÑRÔRÐRØˆr*   c                 ój  — t          d| j        ¦  «        }|                     d¦  «        }t          j        ¦   «         } |d|¦  «        }|                      |t          ¦  «         |                      |j        | j        ¦  «         |                      |g|j	         
                    ¦   «         ¦  «         dS )zÓ
        The I{source} renderer of L{_FrameElement} renders the source code near
        the source filename/line number associated with the frame object used to
        initialize the L{_FrameElement}.
        Nrx   )r   rc   ÚlookupRenderMethodr   rj   ÚassertIsInstancer   ÚassertIdenticalr    ÚloaderÚload©r%   rn   ÚrendererÚtagÚresults        r(   Útest_frameElementSourcez+FailureElementTests.test_frameElementSource  s¡   € õ    d¤jÑ1Ô1ˆØ×-Ò-¨hÑ7Ô7ˆÝŒh‰jŒjˆØ�˜$ Ñ$Ô$ˆØ×Ò˜fÕ&<Ñ=Ô=Ð=Ø×Ò˜Vœ\¨4¬:Ñ6Ô6Ð6Ø×Ò˜#˜ ¤× 2Ò 2Ñ 4Ô 4Ñ5Ô5Ð5Ð5Ð5r*   c                 ó  — t          d| j        j        dd…         ¦  «        }|                     d¦  «        }t	          j        ¦   «         } |d|¦  «        }|                      |t          ¦  «         |                      |d         t          ¦  «         |  	                    |d         j
        | j        j        d         ¦  «         |                      |d         t          ¦  «         |  	                    |d         j
        | j        j        d         ¦  «         |                      |d         j                             ¦   «         |d         j                             ¦   «         ¦  «         |                      dt          |¦  «        ¦  «         dS )zœ
        The I{frames} renderer of L{_StackElement} renders each stack frame in
        the list of frames used to initialize the L{_StackElement}.
        Né   rb   r   rZ   )r   ra   rb   rŒ   r   rj   r�   Úlistr   rŽ   rc   ÚassertNotEqualr�   r�   r    Úlenr‘   s        r(   Útest_stackElementz%FailureElementTests.test_stackElement)  sD  € õ
    d¤lÔ&9¸"¸1¸"Ô&=Ñ>Ô>ˆØ×-Ò-¨hÑ7Ô7ˆÝŒh‰jŒjˆØ�˜$ Ñ$Ô$ˆØ×Ò˜f¥dÑ+Ô+Ð+Ø×Ò˜f Qœi­Ñ7Ô7Ð7Ø×Ò˜V AœYœ_¨d¬lÔ.AÀ!Ô.DÑEÔEÐEØ×Ò˜f Qœi­Ñ7Ô7Ð7Ø×Ò˜V AœYœ_¨d¬lÔ.AÀ!Ô.DÑEÔEÐEà×Ò˜F 1œIÔ,×1Ò1Ñ3Ô3°V¸A´YÔ5E×5JÒ5JÑ5LÔ5LÑMÔMÐMØ×Ò˜�C ™KœKÑ(Ô(Ð(Ð(Ð(r*   c                 ór  — t          | j        ¦  «        }|                     d¦  «        }t          j        ¦   «         } |d|¦  «        }|                      |t          ¦  «         |                      |j        | j        j	        ¦  «         |  
                    |g|j                             ¦   «         ¦  «         dS )zƒ
        The I{traceback} renderer of L{FailureElement} renders the failure's
        stack frames using L{_StackElement}.
        Ú	tracebackN)r   ra   rŒ   r   rj   r�   r   rŽ   ÚstackFramesrb   r    r�   r�   r‘   s        r(   Útest_failureElementTracebackz0FailureElementTests.test_failureElementTraceback;  s¢   € õ
 ! ¤Ñ.Ô.ˆØ×-Ò-¨kÑ:Ô:ˆÝŒh‰jŒjˆØ�˜$ Ñ$Ô$ˆØ×Ò˜f¥mÑ4Ô4Ð4Ø×Ò˜VÔ/°´Ô1DÑEÔEÐEØ×Ò˜#˜ ¤× 2Ò 2Ñ 4Ô 4Ñ5Ô5Ð5Ð5Ð5r*   c                 óÖ   — t          | j        t          t          j        d¬¦  «        ¦  «        ¦  «        }t          d|¦  «        }d}|                     | j        d|z   dz   ¦  «         |S )zi
        The I{type} renderer of L{FailureElement} renders the failure's
        exception type.
        Útyperg   Ns   builtins.Exceptionr   r�   ©r   ra   r   r   rk   r   rl   r    )r%   rn   ro   Úexcs       r(   Útest_failureElementTypez+FailureElementTests.test_failureElementTypeH  sc   € õ
 ! ¤­y½¼È&Ð9QÑ9QÔ9QÑ/RÔ/RÑSÔSˆÝ˜$ Ñ(Ô(ˆØ#ˆØ	�Š�dÔ&¨	°C©¸*Ñ(DÑEÔEÐEØˆr*   c                 óÆ   — t          | j        t          t          j        d¬¦  «        ¦  «        ¦  «        }t          d|¦  «        }|                     | j        d¦  «         |S )zi
        The I{value} renderer of L{FailureElement} renders the value's exception
        value.
        Úvaluerg   Ns   <span>This is a problem</span>r¢   r„   s      r(   Útest_failureElementValuez,FailureElementTests.test_failureElementValueS  sV   € õ
 ! ¤­y½¼È'Ð9RÑ9RÔ9RÑ/SÔ/SÑTÔTˆÝ˜$ Ñ(Ô(ˆØ	�Š�dÔ&Ð(IÑJÔJÐJØˆr*   N)r7   r8   r9   r:   rd   rp   r|   r…   r‡   rŠ   r•   r›   rŸ   r¤   r§   r;   r*   r(   rT   rT       sÄ   € € € € € ðð ð
1ð 1ð 1ð$ð ð ð&(ð (ð (ðTð ð ð 	ð 	ð 	ð	ð 	ð 	ð6ð 6ð 6ð)ð )ð )ð$6ð 6ð 6ð	ð 	ð 	ðð ð ð ð r*   rT   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚFormatFailureTestsz‰
    Tests for L{twisted.web.util.formatFailure} which returns an HTML string
    representing the L{Failure} instance passed to it.
    c                 ó`   — |                       t          t          t          ¦   «         ¦  «         dS )z}
        If there is an error flattening the L{Failure} instance,
        L{formatFailure} raises L{FlattenerError}.
        N)r,   r
   r   ÚobjectrL   s    r(   Útest_flattenerErrorz&FormatFailureTests.test_flattenerErrord  s&   € ð
 	×Ò�.­-½¹¼ÑBÔBÐBÐBÐBr*   c                 ó6  — 	 t          d¦  «        ‚# t          $ r t          t          ¦   «         ¦  «        }Y nw xY w|                      |t
          ¦  «         |                      t          d„ |D ¦   «         ¦  «        ¦  «         |                      d|¦  «         dS )zÕ
        The return value of L{formatFailure} is a C{str} instance (not a
        C{unicode} instance) with numeric character references for any non-ASCII
        characters meant to appear in the output.
        zFake bugc              3   ó"   K  — | ]
}|d k     V — ŒdS )é€   Nr;   )Ú.0Úchs     r(   ú	<genexpr>z7FormatFailureTests.test_returnsBytes.<locals>.<genexpr>w  s&   è è € Ð6Ð6¨˜B šHÐ6Ð6Ð6Ð6Ð6Ð6r*   s   &#160;N)	rW   r`   r   r   r�   rR   Ú
assertTrueÚallÚassertIn)r%   r”   s     r(   Útest_returnsBytesz$FormatFailureTests.test_returnsBytesk  s    € ð	.Ý˜JÑ'Ô'Ð'øÝð 	.ð 	.ð 	.Ý"¥7¡9¤9Ñ-Ô-ˆFˆFˆFð	.øøøð 	×Ò˜f¥eÑ,Ô,Ð,Ø�Š�Ð6Ð6¨vÐ6Ñ6Ô6Ñ6Ô6Ñ7Ô7Ð7à�Š�i Ñ(Ô(Ð(Ð(Ð(s   ‚ ‘%9¸9N)r7   r8   r9   r:   r¬   r¶   r;   r*   r(   r©   r©   ^  s?   € € € € € ðð ð
Cð Cð Cð)ð )ð )ð )ð )r*   r©   c                   ó   — e Zd Zd„ Zd„ ZdS )Ú
SDResourcec                 ó   — || _         d S ©N)Údefault)r%   r»   s     r(   Ú__init__zSDResource.__init__}  s   € ØˆŒˆˆr*   c                 ó~   — t          j        | j        ¦  «        }t          j        |¦  «        } |j        ||¦  «        S rº   )r   Úsucceedr»   r	   r   ÚgetChildWithDefault)r%   Únamer&   ro   r   s        r(   r¿   zSDResource.getChildWithDefault€  s8   € ÝŒM˜$œ,Ñ'Ô'ˆÝÔ(¨Ñ+Ô+ˆØ+ˆxÔ+¨D°'Ñ:Ô:Ð:r*   N)r7   r8   r9   r¼   r¿   r;   r*   r(   r¸   r¸   |  s2   € € € € € ðð ð ð;ð ;ð ;ð ;ð ;r*   r¸   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚDeferredResourceTestsz(
    Tests for L{DeferredResource}.
    c                 óÞ   — t          j        ¦   «         }d|_        t          |¦  «        }t	          g d¢¦  «        }t          j        ||¦  «         |                      |j        ddg¦  «         d S )NrZ   )ÚfooÚbarÚbazrÅ   rÆ   )r   ÚResourceÚisLeafr¸   r   ÚgetChildForRequestr    Úpostpath)r%   ÚrÚsro   s       r(   ÚtestDeferredResourcez*DeferredResourceTests.testDeferredResource‹  sk   € ÝÔÑÔˆØˆŒÝ�q‰MŒMˆÝÐ.Ð.Ð.Ñ/Ô/ˆÝÔ# A qÑ)Ô)Ð)Ø×Ò˜œ e¨U ^Ñ4Ô4Ð4Ð4Ð4r*   c                 ó   — g }t          g ¦  «        }|j        |_        t          j        ¦   «         }t          t          j        |¦  «        ¦  «        }|                     |¦  «         |                      ||g¦  «         dS )z­
        L{DeferredResource} uses the request object's C{render} method to
        render the resource which is the result of the L{Deferred} being
        handled.
        N)	r   ÚappendrE   r   rÇ   r   r   r¾   r    )r%   Úrenderedr&   r”   ÚdeferredResources        r(   Útest_renderz!DeferredResourceTests.test_render“  sw   € ð ˆÝ˜rÑ"Ô"ˆØ!œˆŒåÔ"Ñ$Ô$ˆÝ+­E¬M¸&Ñ,AÔ,AÑBÔBÐØ×Ò Ñ(Ô(Ð(Ø×Ò˜ F 8Ñ,Ô,Ð,Ð,Ð,r*   c                 óÈ  — t          g ¦  «        }|                     ¦   «         }t          t          ¦   «         ¦  «        }t	          t          j        |¦  «        ¦  «        }|                     |¦  «         |                      |  	                    |¦  «        |¦  «         ~t          j        ¦   «          |                      t          ¦  «        }|                      |g ¦  «         dS )z°
        If the L{Deferred} fails, L{DeferredResource} reports the failure via
        C{processingFailed}, and does not cause an unhandled error to be
        logged.
        N)r   ÚnotifyFinishr   ÚRuntimeErrorr   r   ÚfailrE   r    ÚfailureResultOfÚgcÚcollectÚflushLoggedErrors)r%   r&   ro   ra   rÑ   Úerrorss         r(   Útest_renderNoFailurez*DeferredResourceTests.test_renderNoFailure¢  sÀ   € õ ˜rÑ"Ô"ˆØ× Ò Ñ"Ô"ˆÝ�,™.œ.Ñ)Ô)ˆÝ+­E¬J°wÑ,?Ô,?Ñ@Ô@ÐØ×Ò Ñ(Ô(Ð(Ø×Ò˜×-Ò-¨aÑ0Ô0°'Ñ:Ô:Ð:ØÝ
Œ
‰ŒˆØ×'Ò'­Ñ5Ô5ˆØ×Ò˜ Ñ$Ô$Ð$Ð$Ð$r*   N)r7   r8   r9   r:   rÍ   rÒ   rÜ   r;   r*   r(   rÂ   rÂ   †  sK   € € € € € ðð ð5ð 5ð 5ð-ð -ð -ð%ð %ð %ð %ð %r*   rÂ   ),r:   rØ   Útwisted.internetr   Útwisted.python.compatr   Útwisted.python.failurer   Útwisted.trial.unittestr   r   Útwisted.webr   r	   Útwisted.web.errorr
   Útwisted.web.httpr   Útwisted.web.serverr   Útwisted.web.templater   r   r   Útwisted.web.test.requesthelperr   r   Útwisted.web.utilr   r   r   r   r   r   r   r   r   r   r=   rT   r©   rÇ   r¸   rÂ   r;   r*   r(   ú<module>rè      sx  ððð ð 
€	€	€	à "Ð "Ð "Ð "Ð "Ð "Ø /Ð /Ð /Ð /Ð /Ð /Ø *Ð *Ð *Ð *Ð *Ð *Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø "Ð "Ð "Ð "Ð "Ð "Ø &Ð &Ð &Ð &Ð &Ð &Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ Eð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ðE)ð E)ð E)ð E)ð E)�hñ E)ô E)ð E)ðP4
ð 4
ð 4
ð 4
ð 4
Ð-ñ 4
ô 4
ð 4
ðn{ð {ð {ð {ð {˜(ñ {ô {ð {ð|)ð )ð )ð )ð )˜ñ )ô )ð )ð<;ð ;ð ;ð ;ð ;�Ô"ñ ;ô ;ð ;ð+%ð +%ð +%ð +%ð +%Ð/ñ +%ô +%ð +%ð +%ð +%r*   