
    h                        S r  SSKrCSSKJr  SSKJrJr   SSKJr  SSKJrJr  SSKJrJr  SSKJrJrJr  S	S
KJr  SSKJrJr  SSKJrJrJrJrJrJrJ r J!r!J"r"   " S S\5      r#g! \	 a	    SSK
Jr   NXf = f! \	 a     gf = f)!
Tests for hyperlink.hypothesis.
    N)digits)SequenceText)patch)givensettings)SearchStrategydata)	IDNAErrorcheck_labelencode   )HyperlinkTestCase   )
DecodedURL
EncodedURL)	DrawCallable	compositedecoded_urlsencoded_urlshostname_labels	hostnames	idna_textpathsport_numbersc                   6   \ rS rSrSr\" \" 5       5      S 5       r\" \" 5       5      S 5       r	\" \
" 5       5      S 5       r\" \
" SS95      S 5       r\" \" 5       5      S	 5       r\" \" 5       5      \" S
S9S 5       5       r\" \" SS95      S 5       r\" \" 5       5      S 5       r\" \" SS95      S 5       r\" \" SS95      S 5       r\" \" SSS95      S 5       r\" \" 5       5      S 5       r\" \" 5       5      S 5       r\" \" 5       5      S 5       rSrg)TestHypothesisStrategies(   r   c                 l     [        U5        g! [         a    [        SR                  U5      5      ef = f)z,
idna_text() generates IDNA-encodable text.
zInvalid IDNA text: {!r}N)idna_encoder   AssertionErrorformat)selftexts     e/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/hyperlink/test/test_hypothesis.pytest_idna_text_valid-TestHypothesisStrategies.test_idna_text_valid-   s8    MD! M$%>%E%Ed%KLLMs    %3c                     U R                  [        UR                  [        SS95        U R                  [        UR                  [        SS95        g)z7
idna_text() raises AssertionError if min_size is < 1.
r   )min_size)max_sizeN)assertRaisesr"   drawr   )r$   r   s     r&   test_idna_text_min_max/TestHypothesisStrategies.test_idna_text_min_max8   s:     ndiiA9NOndiiA9NO    c                 L    U R                  US5        U R                  US5        g)zC
port_numbers() generates integers between 1 and 65535, inclusive.
r     NassertGreaterEqualassertLessEqualr$   ports     r&   test_port_numbers_bounds1TestHypothesisStrategies.test_port_numbers_boundsA   s$     ##D!,  u-r0   T)
allow_zeroc                 L    U R                  US5        U R                  US5        g)zR
port_numbers(allow_zero=True) generates integers between 0 and
65535, inclusive.
r   r2   Nr3   r6   s     r&   #test_port_numbers_bounds_allow_zero<TestHypothesisStrategies.test_port_numbers_bounds_allow_zeroJ   s$     ##D!,  u-r0   c                      [        U5        [        U5        g! [         a    [        SR	                  U5      5      ef = f)z3
hostname_labels() generates IDN host name labels.
Invalid IDN label: {!r}N)r   r!   UnicodeErrorr"   r#   r$   labels     r&   test_hostname_labels_valid_idn7TestHypothesisStrategies.test_hostname_labels_valid_idnT   s@    NE"E" N$%>%E%Ee%LMMNs    %>
   )max_examplesc                    [         S 5       n[        SU5         UR                  " [        5       5      n [	        U5        [        U5         SSS5        g! [         a    [        SR                  U5      5      ef = f! , (       d  f       g= f)zz
hostname_labels() handles case where idna_text() generates text
that encoded to punycode ends up as longer than allowed.
c                     SU-  $ )N   á )r-   r*   r+   s      r&   mock_idna_textWTestHypothesisStrategies.test_hostname_labels_long_idn_punycode.<locals>.mock_idna_texti   s     >HHr0   zhyperlink.hypothesis.idna_textr?   N)	r   r   r-   r   r   r!   r@   r"   r#   )r$   r   rK   rB   s       r&   &test_hostname_labels_long_idn_punycode?TestHypothesisStrategies.test_hostname_labels_long_idn_punycode`   s     I I 7H		/"34&&	 IH
 $ (188?  IHs   A=A%A::A==
BF)	allow_idnc                      [        U5        UR                  S5        g! [         a    [        SR	                  U5      5      ef = f)z7
hostname_labels() generates a ASCII host name labels.
asciizInvalid ASCII label: {!r}N)r   r   r@   r"   r#   rA   s     r&    test_hostname_labels_valid_ascii9TestHypothesisStrategies.test_hostname_labels_valid_ascii}   sD    PE"W% P$%@%G%G%NOOPs	    %Ac                      UR                  S5       H  n[        U5        M     [        U5        g! [         a    [	        SR                  U5      5      ef = f)z)
hostnames() generates a IDN host names.
.zInvalid IDN host name: {!r}N)splitr   r!   r@   r"   r#   r$   hostnamerB   s      r&   test_hostnames_idn+TestHypothesisStrategies.test_hostnames_idn   sT    %^^D1E& 2H% $188B s	   .1 %A)allow_leading_digitc                 P    U R                  XR                  [        5      :H  5        g)zY
hostnames(allow_leading_digit=False) generates a IDN host names
without leading digits.
N
assertTruelstripr   r$   rX   s     r&   test_hostnames_idn_nolead2TestHypothesisStrategies.test_hostnames_idn_nolead        OOH(??@r0   c                      UR                  S5       H  n[        U5        M     UR                  S5        g! [         a    [	        SR                  U5      5      ef = f)z+
hostnames() generates a ASCII host names.
rU   rQ   zInvalid ASCII host name: {!r}N)rV   r   r   r@   r"   r#   rW   s      r&   test_hostnames_ascii-TestHypothesisStrategies.test_hostnames_ascii   sX    %^^D1E& 2( $3::8D s	   47 %A)r[   rO   c                 P    U R                  XR                  [        5      :H  5        g)zj
hostnames(allow_leading_digit=False, allow_idn=False) generates
ASCII host names without leading digits.
Nr]   r`   s     r&   test_hostnames_ascii_nolead4TestHypothesisStrategies.test_hostnames_ascii_nolead   rc   r0   c                     SR                  U5      n UR                  S5        U H  nU R                  SU5        M     g! [         a    [        SR	                  U5      5      ef = f)z5
paths() generates sequences of URL path components.
/zutf-8zInvalid URL path: {!r}z#/?N)joinr   r@   r"   r#   assertNotIn)r$   pathr%   segments       r&   
test_paths#TestHypothesisStrategies.test_paths   si     99T?DLG$    0     L$%=%D%DT%JKKLs   A   %A%c                 0    U R                  U[        5        g)z'
encoded_urls() generates EncodedURLs.
N)assertIsInstancer   r$   urls     r&   test_encoded_urls*TestHypothesisStrategies.test_encoded_urls        !!#z2r0   c                 0    U R                  U[        5        g)z'
decoded_urls() generates DecodedURLs.
N)rs   r   rt   s     r&   test_decoded_urls*TestHypothesisStrategies.test_decoded_urls   rx   r0   rJ   N)__name__
__module____qualname____firstlineno____doc__r   r   r'   r   r.   r   r8   r<   r   rC   r	   rM   rR   r   rY   ra   re   rh   r   rp   r   rv   r   rz   __static_attributes__rJ   r0   r&   r   r   (   s   	 
y{		M 
	M 
tv	P 
	P 
|~		. 
	. 
|t,	-	. 
.	. 
 	!		N 
"		N 
tv	r	"	 
# 
	6 
/	0		P 
1		P 
y{		 
	 
yU3	4	A 
5	A 
y5)	*	 
+	 
yUeD	E	A 
F	A 
uw	1 
	1 
|~		3 
	3 
|~		3 
	3r0   r   )$r   
hypothesisstringr   typingr   r   unittest.mockr   ImportErrormockr   r	   hypothesis.strategiesr
   r   idnar   r   r   r!   commonr    r   r   r   r   r   r   r   r   r   r   r   r   rJ   r0   r&   <module>r      s   P3 %' +:BB))
 
 
n3#4 n3-    		s"   A: A( (A76A7:BB