+
    Dfj.                         R t ^ RIHt ^ RIHt ^ RIHt  ! R R]P                  4      t ! R R4      t	 ! R R	]	]P                  4      t
 ! R
 R]	]P                  4      t ! R R]	]P                  4      tR# )z)
Tests L{twisted.web.client} helper APIs
)urlparse)unittest)clientc                   0   a  ] tR t^t o RtR tR tRtV tR# )URLJoinTestsz
Tests for L{client._urljoin}.
c                    V P                  \        P                  ! RR4      R4       V P                  \        P                  ! RR4      R4       V P                  \        P                  ! RR4      R4       R# )z
L{client._urljoin} does not include a fragment identifier in the
resulting URL if neither the base nor the new path include a fragment
identifier.
   http://foo.com/bar   /quuxs   http://foo.com/quuxs   http://foo.com/bar#s   /quux#NassertEqualr   _urljoinselfs   &A/usr/lib/python3/dist-packages/twisted/web/test/test_webclient.pytest_noFragmentsURLJoinTests.test_noFragments   sh     	OO18<>T	
 	OO2H=?U	
 	OO19=?U	
    c                    V P                  \        P                  ! RR4      R4       V P                  \        P                  ! RR4      R4       V P                  \        P                  ! RR4      R4       R# )z
L{client._urljoin} preserves the fragment identifier from either the
new path or the base URL respectively, as specified in the HTTP 1.1 bis
draft.

@see: U{https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.2}
s   http://foo.com/bar#fragr	   s   http://foo.com/quux#fragr   s   /quux#frag2s   http://foo.com/quux#frag2Nr
   r   s   &r   test_preserveFragments#URLJoinTests.test_preserveFragments$   sh     	OO6A'	
 	OO1>B(	
 	OO6G(	
r    N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     
 
 
r   r   c                      a  ] tR t^:t o RtR tRR ltR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tRtV tR# )URITestsa  
Abstract tests for L{twisted.web.client.URI}.

Subclass this and L{unittest.TestCase}. Then provide a value for
C{host} and C{uriHost}.

@ivar host: A host specification for use in tests, must be L{bytes}.

@ivar uriHost: The host specification in URI form, must be a L{bytes}. In
    most cases this is identical with C{host}. IPv6 address literals are an
    exception, according to RFC 3986 section 3.2.2, as they need to be
    enclosed in brackets. In this case this variable is different.
c                
   V P                  V P                  \        4       V P                  V P                  \        4       V P                  V\        4       V P	                  RV4       VP                  RV P                  4      # )ai  
Replace the string "HOST" in C{template} with this test's host.

Byte strings Python between (and including) versions 3.0 and 3.4
cannot be formatted using C{%} or C{format} so this does a simple
replace.

@type template: L{bytes}
@param template: A string containing "HOST".

@rtype: L{bytes}
@return: A string where "HOST" has been replaced by C{self.host}.
s   HOST)assertIsInstancehostbytesuriHostassertInreplace)r   templates   &&r   makeURIStringURITests.makeURIStringI   sa     	dii/dllE2h.gx(66r   c
                    V P                  W#WEWgW3VP                  VP                  VP                  VP                  VP
                  VP                  VP                  VP                  34       R# )a  
Assert that all of a L{client.URI}'s components match the expected
values.

@param uri: U{client.URI} instance whose attributes will be checked
    for equality.

@type scheme: L{bytes}
@param scheme: URI scheme specifier.

@type netloc: L{bytes}
@param netloc: Network location component.

@type host: L{bytes}
@param host: Host name.

@type port: L{int}
@param port: Port number.

@type path: L{bytes}
@param path: Hierarchical path.

@type params: L{bytes}
@param params: Parameters for last path segment, defaults to C{b''}.

@type query: L{bytes}
@param query: Query string, defaults to C{b''}.

@type fragment: L{bytes}
@param fragment: Fragment identifier, defaults to C{b''}.
N)	r   schemenetlocr$   portpathparamsqueryfragment)
r   urir-   r.   r$   r/   r0   r1   r2   r3   s
   &&&&&&&&&&r   assertURIEqualsURITests.assertURIEquals]   s\    D 	TuG





				
r   c                   \         P                  P                  V P                  R4      4      pV P	                  ^PVP
                  4       \         P                  P                  V P                  R4      4      pV P	                  ^PVP
                  4       \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       R# )zl
L{client.URI.fromBytes} by default assumes port 80 for the I{http}
scheme and 443 for the I{https} scheme.
   http://HOSTs   http://HOST:   https://HOSTi  Nr   URI	fromBytesr*   r   r/   r   r4   s   & r   test_parseDefaultPortURITests.test_parseDefaultPort   s    
 jj""4#5#5n#EFSXX&jj""4#5#5o#FGSXX&jj""4#5#5o#FGchh'r   c                6   \         P                  P                  V P                  R4      RR7      pV P	                  RVP
                  4       \         P                  P                  V P                  R4      RR7      pV P	                  RVP
                  4       R# )zj
L{client.URI.fromBytes} accepts a C{defaultPort} parameter that
overrides the normal default port logic.
r8     )defaultPortr9   Nr:   r=   s   & r   test_parseCustomDefaultPort$URITests.test_parseCustomDefaultPort   s|    
 jj""4#5#5n#ESW"Xsxx(jj""/T # 
 	sxx(r   c                   \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       V P	                  V P                  VP                  4       V P	                  V P                  R,           VP                  4       \         P                  P                  V P                  R4      4      pV P	                  V P                  VP                  4       R# )zR
Parsing a I{URI} splits the network location component into I{host} and
I{port}.
s   http://HOST:5144rA   s   :5144s   http://HOST N)	r   r;   r<   r*   r   r/   r$   r&   r.   r=   s   & r   test_netlocHostPortURITests.test_netlocHostPort   s    
 jj""4#5#56I#JKsxx(CHH-0#**= jj""4#5#5o#FGszz2r   c           	         V P                  R4      p\        P                  P                  V4      pV P	                  VRV P
                  V P                  ^PRR7       V P                  WP                  4       4       R# )z
Parse the path from a I{URI}.
s   http://HOST/foo/bar   http   /foo/barr-   r.   r$   r/   r0   N	r*   r   r;   r<   r5   r&   r$   r   toBytesr   r4   parseds   &  r   	test_pathURITests.test_path   sm       !78%%c*<< 	 	
 	nn./r   c           	         V P                  R4      p\        P                  P                  V4      pV P	                  VRV P
                  V P                  ^PRR7       V P                  WP                  4       4       R# )z<
The path of a I{URI} that has no path is the empty string.
r8   rI   r   rK   NrL   rN   s   &  r   test_noPathURITests.test_noPath   sl       0%%c*<< 	 	
 	nn./r   c           	         V P                  R4      pV P                  \        P                  P	                  V4      RV P
                  V P                  ^PRR7       R# )z5
The path of a I{URI} with an empty path is C{b'/'}.
   http://HOST/rI      /rK   N)r*   r5   r   r;   r<   r&   r$   r=   s   & r   test_emptyPathURITests.test_emptyPath   sP       1JJ  %<< 	 	
r   c           
         V P                  R4      p\        P                  P                  V4      pV P	                  VRV P
                  V P                  ^PRRR7       V P                  WP                  4       4       R# )z(
Parse I{URI} parameters from a I{URI}.
s   http://HOST/foo/bar;paramrI   rJ      param)r-   r.   r$   r/   r0   r1   NrL   rN   s   &  r   
test_paramURITests.test_param   sp       !=>%%c*<< 	 	
 	nn./r   c                    V P                  R4      p\        P                  P                  V4      pV P	                  VRV P
                  V P                  ^PRRRR7       V P                  WP                  4       4       R# )z'
Parse the query string from a I{URI}.
s!   http://HOST/foo/bar;param?a=1&b=2rI   rJ   r[      a=1&b=2)r-   r.   r$   r/   r0   r1   r2   NrL   rN   s   &  r   
test_queryURITests.test_query   ss       !EF%%c*<< 	 		
 	nn./r   c                    V P                  R4      p\        P                  P                  V4      pV P	                  VRV P
                  V P                  ^PRRRRR7	       V P                  WP                  4       4       R# )	z.
Parse the fragment identifier from a I{URI}.
s&   http://HOST/foo/bar;param?a=1&b=2#fragrI   rJ   r[   r_   s   frag)r-   r.   r$   r/   r0   r1   r2   r3   NrL   rN   s   &  r   test_fragmentURITests.test_fragment  sv       !JK%%c*<< 	 
	
 	nn./r   c                    \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       R# )zV
L{client.URI.originForm} produces an absolute I{URI} path including
the I{URI} path.
s   http://HOST/foos   /fooNr   r;   r<   r*   r   
originFormr=   s   & r   test_originFormURITests.test_originForm  s8    
 jj""4#5#56H#IJ#..1r   c                    \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       R# )z
L{client.URI.originForm} produces an absolute I{URI} path including
the I{URI} path, parameters and query string but excludes the fragment
identifier.
s   http://HOST/foo;param?a=1#frags   /foo;param?a=1Nrf   r=   s   & r   test_originFormComplexURITests.test_originFormComplex   s>     jj""@A
 	*CNN;r   c                    \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       R# )zX
L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
specifies no path.
r8   rW   Nrf   r=   s   & r   test_originFormNoPathURITests.test_originFormNoPath+  s7    
 jj""4#5#5n#EFs~~.r   c                    \         P                  P                  V P                  R4      4      pV P	                  RVP
                  4       R# )z^
L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
specifies an empty path.
rV   rW   Nrf   r=   s   & r   test_originFormEmptyPath!URITests.test_originFormEmptyPath3  s7    
 jj""4#5#5o#FGs~~.r   c                ^   V P                  R4      pVP                  R4      p\        V4       \        P                  P                  V4      pV P                  VP                  \        4       V P                  VP                  \        4       V P                  VP                  \        4       R# )z
L{client.URI.fromBytes} parses the scheme, host, and path elements
into L{bytes}, even when passed an URL which has previously been passed
to L{urlparse} as a L{unicode} string.
s   http://HOST/pathasciiN)r*   decoder   r   r;   r<   r#   r-   r%   r$   r0   )r   	goodInputbadInputr4   s   &   r    test_externalUnicodeInterference)URITests.test_externalUnicodeInterference;  s}     &&':;	##G,jj""9-cjj%0chh.chh.r   r   N)r   r   r   )r   r   r   r   r   r*   r5   r>   rC   rF   rP   rS   rX   r\   r`   rc   rh   rk   rn   rq   rx   r   r   r   s   @r   r!   r!   :   s`     7(.
`(
)30 0 
0"0$0&2	</// /r   r!   c                   "    ] tR tRtRtR;ttRtR# )URITestsForHostnameiJ  z6
Tests for L{twisted.web.client.URI} with host names.
s   example.comr   Nr   r   r   r   r   r&   r$   r   r   r   r   r{   r{   J  s     $#Gdr   r{   c                   "    ] tR tRtRtR;ttRtR# )URITestsForIPv4iR  z?
Tests for L{twisted.web.client.URI} with IPv4 host addresses.
s   192.168.1.67r   Nr|   r   r   r   r~   r~   R  s     %$Gdr   r~   c                   2   a  ] tR tRt o RtRtRtR tRtV t	R# )URITestsForIPv6iZ  z
Tests for L{twisted.web.client.URI} with IPv6 host addresses.

IPv6 addresses must always be surrounded by square braces in URIs. No
attempt is made to test without.
s   fe80::20c:29ff:fea4:c60s   [fe80::20c:29ff:fea4:c60]c                    \         P                  P                  R4      pV P                  VP                  R4       V P                  VP
                  R4       V P                  VP                  4       R4       R# )z
Brackets around IPv6 addresses are stripped in the host field. The host
field is then exported with brackets in the output of
L{client.URI.toBytes}.
s   http://[::1]:80/index.htmls   ::1s   [::1]:80N)r   r;   r<   r   r$   r.   rM   r=   s   & r   "test_hostBracketIPv6AddressLiteral2URITestsForIPv6.test_hostBracketIPv6AddressLiterale  sX     jj""#@A6*[1(EFr   r   N)
r   r   r   r   r   r$   r&   r   r   r   r   s   @r   r   r   Z  s"      &D*G
G 
Gr   r   N)r   urllib.parser   twisted.trialr   twisted.webr   TestCaser   r!   r{   r~   r   r   r   r   <module>r      ss   
 " " (
8$$ (
VM/ M/`$(H$5$5 $%h 1 1 %Gh 1 1 Gr   