
    ϶vgG"                         d dl Zd dlZd dlZd dlZd dlmZ d dlZd dl	Z
d dlZ G d d          Z G d d          Z G d d          Zej                            d	          d
             ZdS )    N)cleandocc                   \    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 ZdS )TestPackageIndexc                     d}|dz  } d                                 j        di t                      }t          j        j                            |          sJ d S )Nz&http://other_url?:action=show_md5&amp;z'digest=0123456789abcdef0123456789abcdefz
            <a href="http://some_url">Name</a>
            (<a title="MD5 hash"
            href="{hash_url}">md5</a>)
         )lstripformatlocals
setuptoolspackage_indexPYPI_MD5match)selfhash_urldocs      _/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/tests/test_packageindex.py
test_regexzTestPackageIndex.test_regex   sp    ;==  FHHV	( ( %hh	( (
 '066s;;;;;;;    c                 @   t           j                                        }d}t          j        t
          t          j        |                    5  |                    |          }t          |t          j        j                  sJ 	 d d d            d S # 1 swxY w Y   d S )Nz.http://127.0.0.1:0/nonesuch/test_package_indexr   r   r   PackageIndexpytestraises	Exceptionreescapeopen_url
isinstanceurlliberror	HTTPErrorr   indexurlvs       r   test_bad_url_bad_portz&TestPackageIndex.test_bad_url_bad_port   s    (5577>]9BIcNN;;; 	9 	9s##Aa!7888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s   7BBBc                 D   t           j                            d          }d}t          j        t
          t          j        |                    5  |                    |          }t          |t          j        j                  sJ 	 d d d            d S # 1 swxY w Y   d S )Nzwww.example.comhostszMurl:%20https://svn.plone.org/svn/collective/inquant.contentmirror.plone/trunkr   r   r#   s       r   test_bad_url_typoz"TestPackageIndex.test_bad_url_typo    s     (55<P5QQ]]9BIcNN;;; 	9 	9s##Aa!7888888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9s   7BBBc                     t           j                            d          }d }||_        d}t	          j        t          d          5  |                    |           d d d            d S # 1 swxY w Y   d S )Nr)   r*   c                  @    t           j                            d          )Nline)httpclientBadStatusLine)argss    r   _urlopenz?TestPackageIndex.test_bad_url_bad_status_line.<locals>._urlopen/   s    +++F333r   zhttp://example.comr/   r   )r   r   r   openerr   r   r   r   )r   r$   r4   r%   s       r   test_bad_url_bad_status_linez-TestPackageIndex.test_bad_url_bad_status_line,   s    (55<P5QQ	4 	4 	4  "]9G444 	  	 NN3	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   A++A/2A/c                    t           j                            d          }d}	 |                    |           n?# t          j        j        $ r(}t          |          }d|v s
d|v sd|v sJ Y d}~dS d}~ww xY wt          d          )	zO
        A bad URL with a double scheme should raise a DistutilsError.
        r)   r*   z2http://http://svn.pythonpaste.org/Paste/wphp/trunkznonnumeric portzgetaddrinfo failedzName or service not knownNzDid not raise)	r   r   r   r   	distutilserrorsDistutilsErrorstrRuntimeError)r   r$   r%   r!   msgs        r   test_bad_url_double_schemez+TestPackageIndex.test_bad_url_double_scheme7   s     (55<P5QQ C		NN3. 	 	 	e**C!S(('3...#5555FFFFF	 ?+++s   : A6A11A6c                 z    t           j                            d          }d}|                    |d          sJ d S )Nr)   r*   zfile:///tmp/test_package_indexT)r   r   r   url_ok)r   r$   r%   s      r   test_url_okzTestPackageIndex.test_url_okK   sA    (55<P5QQ.||C&&&&&&&r   c                     t           j        j        } |d          }d}||k    sJ  |d          }d}||k    sJ  |d          }d}||k    sJ  |d          }d}||k    sJ d S )	Nzreportlab-2.5.win32-py2.4.exe)reportlab-2.5z2.4win32zreportlab-2.5.win32.exe)rC   NrD   z!reportlab-2.5.win-amd64-py2.7.exe)rC   z2.7	win-amd64zreportlab-2.5.win-amd64.exe)rC   NrE   )r   r   parse_bdist_wininst)r   parseactualexpecteds       r   test_parse_bdist_wininstz)TestPackageIndex.test_parse_bdist_wininstP   s    (<6772!!!!0111!!!!:;;6!!!!4555!!!!!!r   c                 n    t           j        j        j        } |d          \  }}|dk    sJ |dk    sJ dS )zA
        Test the basic usage of _vcs_split_rev_from_url
        zhttps://example.com/bar@2995zhttps://example.com/bar2995N)r   r   r   _vcs_split_rev_from_url)r   vsrfur%   revs       r   test__vcs_split_rev_from_urlz-TestPackageIndex.test__vcs_split_rev_from_urlc   sI     (5M5788S/////f}}}}}}r   c                 f   |dz  }|                     d          5 }|                    d           ddd           n# 1 swxY w Y   dt          j                            t          |                    z   dz   }t          j                            |          }d|	                                v sJ dS )zR
        local_open should be able to read an index from the file system.
        z
index.htmlwz<div>content</div>Nzfile:/content)
openwriter    requestpathname2urlr;   r   r   
local_openread)r   tmpdir
index_filefr%   ress         r   test_local_indexz!TestPackageIndex.test_local_indexl   s     l*
__S!! 	*QGG()))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*33CKK@@@3F&11#66CHHJJ&&&&&&s   =AAc                   	
 ddg}g d
g d	dgdgg d	
fd|D             }|D ]Z\  }}t          t          j                            d	|z                       }|d
         j        dk    sJ |d         j        |k    sJ [dS )z6
        EGG fragments must comply to PEP 440
         z1!)0z0.0z0.0.0)a0b0rc0z.post0z.dev0))ra   ra   )	+ubuntu.0rf   )z	+ubuntu-0rf   )z	+ubuntu_0rf   c                 x    g | ]3	D ].t          gd g          D ]D ]}fd|D             /4S )ra   c                 B    g | ]}d                      |g          S )ra   )join).0loceprs     r   
<listcomp>zATestPackageIndex.test_egg_fragment.<locals>.<listcomp>.<listcomp>   s-    555RWWaAs^$$555r   )sum)
rj   locsrl   rm   rn   devlocalpostprereleasess
     @@@r   ro   z6TestPackageIndex.test_egg_fragment.<locals>.<listcomp>   s     
 
 

 
 #tS)B400	
 
 
 

 	 655555555
 
 
 
 
 
r   z3http://example.com/example-foo.zip#egg=example-foo-r      N)listr   r   distros_for_urlversion)r   epochversionsr&   vcdistsrr   rs   rt   ru   rv   s         @@@@@r   test_egg_fragmentz"TestPackageIndex.test_egg_fragmentw   s   
 

 
 


 
 

 z

 
 

 
 
 
 
 
 
 

 
 
  	* 	*EAr(88IAM  E
 8#r))))8#r)))))	* 	*r   c                 D   d}t           j                                        }|dz  }|                    dddd|g           |                    dd|ddd	g           |                    ||          }|t          |          k    sJ t          |j                  d
k    sJ d S )Nz7git+https://github.example/group/project@master#egg=foozproject@mastergitclone--quiet$https://github.example/group/projectz-Ccheckoutmaster   )r   r   r   registerdownloadr;   lencalls)r   tmp_pathfpr%   r$   expected_dirresults          r   test_download_git_with_revz+TestPackageIndex.test_download_git_with_rev   s    G(5577"22
2
 	 	 	 	UD,
IxPQQQX..\******28}}!!!!!!r   c                     d}t           j                                        }|dz  }|                    dddd|g           |                    ||           d S )Nz0git+https://github.example/group/project#egg=fooprojectr   r   r   r   )r   r   r   r   r   )r   r   r   r%   r$   r   s         r   test_download_git_no_revz)TestPackageIndex.test_download_git_no_rev   sk    @(5577)+
2
 	 	 	 	sH%%%%%r   c                     d}t           j                                        }d}t          j        t
          j        j        |          5  |                    ||           d d d            d S # 1 swxY w Y   d S )Nz'svn+https://svn.example/project#egg=fooz!.*SVN download is not supported.*r   )	r   r   r   r   r   r8   r9   r:   r   )r   r   r%   r$   r=   s        r   test_download_svnz"TestPackageIndex.test_download_svn   s    7(55772]9+:#FFF 	* 	*NN3)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   A,,A03A0N)__name__
__module____qualname__r   r'   r,   r6   r>   rA   rJ   rP   r_   r   r   r   r   r   r   r   r   r      s        < < <9 9 9
9 
9 
9	  	  	 , , ,(' ' '
" " "&  	' 	' 	'** ** **X" " "&& & &* * * * *r   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestContentCheckersc                    t           j        j                            d          }|                    d                    d                     |j                                        dk    sJ |                                sJ d S )N3http://foo/bar#md5=f12895fdffbd45007040d2e44df98478z$You should probably not be using MD5ascii f12895fdffbd45007040d2e44df98478)	r   r   HashCheckerfrom_urlfeedencodehash	hexdigestis_validr   checkers     r   test_md5zTestContentCheckers.test_md5   s    *6??A
 
 	;BB7KKLLL|%%''+MMMMM!!!!!!!r   c                     t           j        j                            d          }|                    d                    d                     |                                sJ dS )z<Content checks should succeed silently if no hash is presentz1http://foo/bar#something%20completely%20differentanythingr   Nr   r   r   r   r   r   r   r   s     r   test_other_fragmentz'TestContentCheckers.test_other_fragment   s`    *6???
 
 	Z&&w//000!!!!!!!r   c                     t           j        j                            d          }|                    d                    d                     |                                sJ dS )z0Content checks should succeed if a hash is emptyzhttp://foo/bar#md5=r   r   Nr   r   s     r   test_blank_md5z"TestContentCheckers.test_blank_md5   sZ    *6??@UVVZ&&w//000!!!!!!!r   c                 h    t           j        j                            d          }|j        dk    sJ d S )Nr   md5)r   r   r   r   	hash_namer   s     r   test_get_hash_name_md5z*TestContentCheckers.test_get_hash_name_md5   s<    *6??A
 
  E))))))r   c                     t           j        j                            d          }|                    d d          }|dk    sJ d S )Nr   c                     | S )Nr   )xs    r   <lambda>z1TestContentCheckers.test_report.<locals>.<lambda>   s    q r   zMy message about %szMy message about md5)r   r   r   r   report)r   r   reps      r   test_reportzTestContentCheckers.test_report   sP    *6??A
 
 nn[[*?@@,,,,,,,r   N)r   r   r   r   r   r   r   r   r   r   r   r   r      s_        " " "" " "" " "* * *- - - - -r   r   c                       e Zd Zd ZdS )TestPyPIConfigc                     |dz  }|                     t          d          d           t          j                                        }|j        d         }|j        dk    sJ |j        dk    sJ d S )Nz.pypircz
                [pypi]
                repository=https://pypi.org
                username=jaraco
                password=pity%
                zutf-8)encodingzhttps://pypi.orgjaracozpity%)
write_textr   r   r   
PyPIConfigcreds_by_repositoryusernamepassword)r   tmp_home_dirpypirccfgcreds        r   test_percent_in_passwordz'TestPyPIConfig.test_percent_in_password   s    	)   	 
	
 
	
 
	
 &1133&'9:}((((}''''''r   N)r   r   r   r   r   r   r   r   r      s#        ( ( ( ( (r   r   rw   c                  N    t           j        j                            d           dS )z;
    REL should not hang on a contrived attack string.
    a  < rel=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                N)r   r   RELsearchr   r   r   test_REL_DoSr     s%    
  ''(>?????r   )http.clientr0   r   urllib.errorr    urllib.requestinspectr   r   setuptools.package_indexr   distutils.errorsr8   r   r   r   marktimeoutr   r   r   r   <module>r      s"       				                       |* |* |* |* |* |* |* |*~"- "- "- "- "- "- "- "-J( ( ( ( ( ( ( (( Q@ @ @ @ @r   