+
    Dfj'                         R t ^ RIHt ^ RIHt  ! R R4      t ! R R]]P                  4      t ! R R]]P                  4      t ! R	 R
]]P                  4      t	R# )z&
Tests for L{twisted.python.urlpath}.
)urlpath)unittestc                   r   a  ] tR t^t o RtR tR t]3R ltR t	R t
R tR tR	 tR
 tR tR tR tRtV tR# )_BaseURLPathTestsz-
Tests for instantiated L{urlpath.URLPath}s.
c                   V P                  V P                  P                  \        4       V P                  V P                  P                  \        4       V P                  V P                  P                  \        4       V P                  V P                  P
                  \        4       V P                  V P                  P                  \        4       R# )zA
All of the attributes of L{urlpath.URLPath} should be L{bytes}.
NassertIsInstancepathschemebytesnetlocqueryfragmentselfs   &B/usr/lib/python3/dist-packages/twisted/python/test/test_urlpath.pytest_partsAreBytes$_BaseURLPathTests.test_partsAreBytes        	dii..6dii..6diinne4diioou5dii00%8    c                t    V P                  \        V P                  P                  4       4      \        4       R# )zA
Calling C{str()} with a L{URLPath} will always return a L{str}.
N)assertEqualtyper	   __str__strr   s   &r   test_strReturnsStr$_BaseURLPathTests.test_strReturnsStr   s&     	dii//12C8r   c                ^   V! R4      V P                   n        V P                  \        V P                   4      R4       V! R4      V P                   n        V P                  \        V P                   4      R4       V! R4      V P                   n         V P                  \        V P                   4      R4       V! R4      V P                   n        V P                  \        V P                   4      R4       V! R	4      V P                   n        V P                  \        V P                   4      R
4       R# )a  
Setting attributes on L{urlpath.URLPath} should change the value
returned by L{str}.

@param stringType: a callable to parameterize this test for different
    text types.
@type stringType: 1-argument callable taking L{str} and returning
    L{str} or L{bytes}.
httpsz0https://example.com/foo/bar?yes=no&no=yes#footerzanother.example.invalidz<https://another.example.invalid/foo/bar?yes=no&no=yes#footerz/helloz:https://another.example.invalid/hello?yes=no&no=yes#footerzalpha=omega&opposites=samezGhttps://another.example.invalid/hello?alpha=omega&opposites=same#footerheaderzGhttps://another.example.invalid/hello?alpha=omega&opposites=same#headerN)r	   r
   r   r   r   r   r   )r   
stringTypes   &&r   test_mutabilityWithText)_BaseURLPathTests.test_mutabilityWithText"   s     &g.				NN	
 &&?@				NJ	
 $H-				NX	
 %%AB				N	

 (1				N	
r   c                *    V P                  R 4       R# )z3
Same as L{test_mutabilityWithText} but for bytes.
c                 $    V P                  R 4      # )ascii)encode)xs   &r   <lambda><_BaseURLPathTests.test_mutabilityWithBytes.<locals>.<lambda>J   s    qxx/@r   N)r!   r   s   &r   test_mutabilityWithBytes*_BaseURLPathTests.test_mutabilityWithBytesF   s     	$$%@Ar   c                   V P                  V P                  P                  \        4       V P                  V P                  P                  \        4       V P                  V P                  P                  \        4       V P                  V P                  P
                  \        4       V P                  V P                  P                  \        4       R# )z,
A created L{URLPath} has bytes attributes.
Nr   r   s   &r   test_allAttributesAreBytes,_BaseURLPathTests.test_allAttributesAreBytesL   r   r   c                P    V P                  \        V P                  4      R4       R# )z[
Calling C{str()} with a L{URLPath} will return the same URL that it was
constructed with.
/http://example.com/foo/bar?yes=no&no=yes#footerN)r   r   r	   r   s   &r   test_stringConversion'_BaseURLPathTests.test_stringConversionV   s     
 			NM	
r   c           	     `   V P                  \        V P                  P                  R4      4      R4       V P                  \        V P                  P                  R4      P                  R4      4      R4       V P                  \        V P                  P                  RRR7      4      R4       R# )	zv
Calling C{str()} with a C{URLPath.child()} will return a URL which is
the child of the URL it was instantiated with.
s   helloz http://example.com/foo/bar/hellor   z!http://example.com/foo/bar/hello/T	keepQueryz.http://example.com/foo/bar/hello?yes=no&no=yesN)r   r   r	   childr   s   &r   test_childString"_BaseURLPathTests.test_childString_   s    
 			)*,N	
 			)//45/	
 			D9:<	
r   c           	     `   V P                  \        V P                  P                  R4      4      R4       V P                  \        V P                  P                  RRR7      4      R4       V P                  \        V P                  P	                  R4      P                  R4      4      R4       R# )	zz
Calling C{str()} with a C{URLPath.sibling()} will return a URL which is
the sibling of the URL it was instantiated with.
   bazzhttp://example.com/foo/bazTr4   z(http://example.com/foo/baz?yes=no&no=yesr   zhttp://example.com/foo/bar/bazN)r   r   r	   siblingr6   r   s   &r   test_siblingString$_BaseURLPathTests.test_siblingStringp   s    
 	TYY..v679UV		!!&D!9:6	
 			$,,V457W	
r   c                   V P                  \        V P                  P                  4       4      R4       V P                  \        V P                  P                  RR7      4      R4       V P                  \        V P                  P	                  R4      P                  4       4      R4       V P                  \        V P                  P	                  R4      P                  4       4      R4       V P                  \        V P                  P                  4       P                  4       P                  4       P                  4       P                  4       4      R4       R# )	zx
Calling C{str()} with a C{URLPath.parent()} will return a URL which is
the parent of the URL it was instantiated with.
zhttp://example.com/Tr4   z!http://example.com/?yes=no&no=yesr   http://example.com/foo/r:   N)r   r   r	   parentr6   r   s   &r   test_parentString#_BaseURLPathTests.test_parentString   s     	TYY--/02GH		  4 013V	
 	TYY__S188:;=VW		'..013L	
 			  "))+224;;=DDFG!	
r   c                Z   V P                  \        V P                  P                  4       4      R4       V P                  \        V P                  P                  RR7      4      R4       V P                  \        V P                  P	                  R4      P                  4       4      R4       R# )z
Calling C{str()} with a C{URLPath.here()} will return a URL which is
the URL that it was instantiated with, without any file, query, or
fragment.
r?   Tr4   z%http://example.com/foo/?yes=no&no=yesr   zhttp://example.com/foo/bar/N)r   r   r	   herer6   r   s   &r   test_hereString!_BaseURLPathTests.test_hereString   s~     	TYY^^-.0IJ		./1X	
 			$))+,.K	
r   c                    V P                  \        V P                  P                  R4      4      P	                  R4      R4       R# )z
Calling L{urlpath.URLPath.click} on a L{urlpath.URLPath} with a
trailing slash with a relative URL containing a leading slash will
result in a URL with a single slash at the start of the path portion.
s   /hello/worldr%   s   http://example.com/hello/worldN)r   r   r	   clickr&   r   s   &r   test_doubleSlash"_BaseURLPathTests.test_doubleSlash   s5     			0188A-	
r   c                p   V P                  V P                  P                  R4      P                  4       . RO4       V P                  V P                  P                  R4      P                  RR7      . RO4       V P                  V P                  P                  R4      P                  RR7      . RO4       R# )	z<
L{urlpath.URLPath.pathList} returns a L{list} of L{bytes}.
	   %00%01%02F)copyT)unquoteN)r      foo   barrL   )r   rO   rP   s    )r   r	   r6   pathListr   s   &r   test_pathList_BaseURLPathTests.test_pathList   s     	IIOOL)224/	
 	IIOOL)222>/	
 	IIOOL)2242@2	
r    N)__name__
__module____qualname____firstlineno____doc__r   r   r   r!   r*   r-   r1   r7   r<   rA   rE   rI   rR   __static_attributes____classdictcell____classdict__s   @r   r   r      sR     99 25 "
HB9

"
&
(
	

 
r   r   c                   B   a  ] tR t^t o RtR tR tR tR tR t	Rt
V tR# )	BytesURLPathTestszD
Tests for interacting with a L{URLPath} created with C{fromBytes}.
c                N    \         P                  P                  R 4      V n        R# )s/   http://example.com/foo/bar?yes=no&no=yes#footerN)r   URLPath	fromBytesr	   r   s   &r   setUpBytesURLPathTests.setUp   s    OO-->
	r   c                h   V P                  \        4      ;_uu_ 4        \        P                  P	                  R4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  P	                  R4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)z5
L{URLPath.fromBytes} must take a L{bytes} argument.
Nsomeurl)assertRaises
ValueErrorr   ra   rb   r   s   &r   test_mustBeBytes"BytesURLPathTests.test_mustBeBytes   sn     z**OO%%d+ + z**OO%%i0 +* +* +**    B# B B	 B1	c                f    \         P                  ! 4       pV P                  \        V4      R4       R# )zX
An instantiation with no arguments creates a usable L{URLPath} with
default arguments.
zhttp://localhost/N)r   ra   r   r   r   urls   & r   test_withoutArguments'BytesURLPathTests.test_withoutArguments   s%    
 ooS#67r   c                   \         P                  P                  R4      pV P                  VP                  R4       V P                  VP
                  R4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP                  R4       V P                  \        V4      R4       R# )zq
Leaving some optional arguments unfilled makes a L{URLPath} with those
optional arguments filled with defaults.
s   http://google.coms   https
   google.com   /r   zhttp://google.com/N)
r   ra   rb   r   r
   r   r	   r   r   r   rm   s   & r   test_partialArguments'BytesURLPathTests.test_partialArguments   s     oo''(<=W-]34(s+C(S#78r   c                z    \         P                  P                  R4      pV P                  \	        V4      R4       R# )zG
L{URLPath.fromBytes} can interpret non-ASCII bytes as percent-encoded
s   http://example.com/ zhttp://example.com/%FF%00N)r   ra   rb   r   r   rm   s   & r   test_nonASCIIBytes$BytesURLPathTests.test_nonASCIIBytes   s.     oo''(FGS#>?r   r	   N)rU   rV   rW   rX   rY   rc   ri   ro   rs   rv   rZ   r[   r\   s   @r   r_   r_      s*     

189@ @r   r_   c                   0   a  ] tR t^t o RtR tR tRtV tR# )StringURLPathTests[
Tests for interacting with a L{URLPath} created with C{fromString} and a
L{str} argument.
c                N    \         P                  P                  R 4      V n        R# r0   Nr   ra   
fromStringr	   r   s   &r   rc   StringURLPathTests.setUp      OO..=
	r   c                h   V P                  \        4      ;_uu_ 4        \        P                  P	                  R4       RRR4       V P                  \        4      ;_uu_ 4        \        P                  P	                  R4       RRR4       R#   + '       g   i     LW; i  + '       g   i     R# ; i)z>
C{URLPath.fromString} must take a L{str} or L{str} argument.
Ns   someurl)rg   rh   r   ra   r   r   s   &r   test_mustBeStr!StringURLPathTests.test_mustBeStr  sn     z**OO&&t, + z**OO&&z2 +* +* +**rk   rx   N)	rU   rV   rW   rX   rY   rc   r   rZ   r[   r\   s   @r   rz   rz      s     


3 3r   rz   c                   0   a  ] tR tRt o RtR tR tRtV tR# )UnicodeURLPathTestsi  r{   c                N    \         P                  P                  R 4      V n        R# r}   r~   r   s   &r   rc   UnicodeURLPathTests.setUp  r   r   c                z    \         P                  P                  R4      pV P                  \	        V4      R4       R# )z6
L{URLPath.fromString} can load non-ASCII characters.
u   http://example.com/ÿ zhttp://example.com/%C3%BF%00N)r   ra   r   r   r   rm   s   & r   test_nonASCIICharacters+UnicodeURLPathTests.test_nonASCIICharacters  s.     oo(()FGS#ABr   rx   N)	rU   rV   rW   rX   rY   rc   r   rZ   r[   r\   s   @r   r   r     s     


C Cr   r   N)
rY   twisted.pythonr   twisted.trialr   r   TestCaser_   rz   r   rT   r   r   <module>r      sc   
 # "x
 x
v0@)8+<+< 0@f3*H,=,= 3,C+X->-> Cr   