o
    UhZ                     @   s  d dl Z d dlZdd Zdd Zdd Zdd	 Zd
d Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdddZdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Zd=d> Zd?d@ Z dAdB Z!dCdD Z"dEdF Z#dGdH Z$dIdJ Z%dKdL Z&dMdN Z'dOdP Z(dQdR Z)dSdT Z*dUdV Z+dWdX Z,dYdZ Z-d[d\ Z.d]d^ Z/d_d` Z0dadb Z1dcdd Z2dedf Z3dgdh Z4didj Z5dkdl Z6dmdn Z7dodp Z8dqdr Z9dsdt Z:dudv Z;dwdx Z<dydz Z=d{d| Z>d}d~ Z?dd Z@dd ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdS )    Nc                  C   2   ddl m}  d}|d}| |}||ksJ d S )Nr   _must_decode   Ézlatin-1pkginfo.distributionr   encoder   	TO_ENCODEencodeddecoded r   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/pkginfo/tests/test_distribution.py test__must_decode_w_bytes_latin1   
   
r   c                  C   r   )Nr   r   r   zutf-8r   r	   r   r   r   test__must_decode_w_bytes_utf8   r   r   c                  C   s(   ddl m}  d}| |}||ksJ d S )Nr   r   r   )r   r   r   ARGr   r   r   r   test__must_decode_w_unicode   s   r   c                  C   s*   ddl m}  t }| |}||u sJ d S )Nr   r   )r   r   objectr   r   r   r   test__must_decode_w_object   s   r   c                  C   &   ddl m}  d}| d||ksJ d S )Nr   _collapse_leading_wsz=This is a description without newlines or leading whitespace.Descriptionr   r   r   DESCRIPTIONr   r   r   8test__collapse_leading_ws_w_descr_one_line_wo_leading_ws#      r   c                  C   *   ddl m}  d}| d|| ksJ d S )Nr   r   z@        This is a description with leading whitespace: strip it.r   r   r   stripr   r   r   r   7test__collapse_leading_ws_w_descr_one_line_w_leading_ws+      r#   c                  C   r   )Nr   r   zlThis is a description with newlines but without leading whitespace.

We expect the newlines to be preserved.r   r   r   r   r   r   :test__collapse_leading_ws_w_descr_multi_line_wo_leading_ws3   s   r%   c                  C   *   ddl m}  d}d}| d||ksJ d S )Nr   r   z        This is a description with newlines and leading whitespace.

        The newlines should be preserved, and the whitespace strippedzzThis is a description with newlines and leading whitespace.

The newlines should be preserved, and the whitespace strippedr   r   r   r   EXPECTEDr   r   r   9test__collapse_leading_ws_w_descr_multi_line_w_leading_ws=   s   r)   c                  C   r&   )Nr   r   zThis is a description with newlines.

        Some lines have leading whitespace.

        The newlines should be preserved, and the whitespace strippedzThis is a description with newlines.

Some lines have leading whitespace.

The newlines should be preserved, and the whitespace strippedr   r   r'   r   r   r   ?test__collapse_leading_ws_w_descr_multi_line_w_mixed_leading_wsM   s   r*   c                  C   r   )Nr   r   z=This is a field value without newlines or leading whitespace.Otherr   r   OTHERr   r   r   8test__collapse_leading_ws_w_other_one_line_wo_leading_ws`   r   r.   c                  C   r    )Nr   r   z@        This is a field value with leading whitespace: strip it.r+   r!   r,   r   r   r   7test__collapse_leading_ws_w_other_one_line_w_leading_wsh   r$   r/   c                  C   r&   )Nr   r   zOThis is a field value with newlines.

We expect them to be converted to spaces.zOThis is a field value with newlines.  We expect them to be converted to spaces.r+   r   r   r-   r(   r   r   r   :test__collapse_leading_ws_w_other_multi_line_wo_leading_wsp   s   r1   c                  C   r&   )Nr   r   zThis is a field value with newlines and leading whitespace.

We expect newlines to be converted to spaces.

We expect the leading whitespace to be stripped.zThis is a field value with newlines and leading whitespace.  We expect newlines to be converted to spaces.  We expect the leading whitespace to be stripped.r+   r   r0   r   r   r   9test__collapse_leading_ws_w_other_multi_line_w_leading_ws~   s   r2   1.0c                 C   s$   ddl m} | }| d ur| |_|S )Nr   )Distribution)r   r4   metadata_version)r5   r4   distr   r   r   _make_distribution   s
   r7   c                  C   s  t d } | jd ksJ | jd ksJ | jd ksJ | jdks J | jdks'J | jd ks.J | jd ks5J | jd ks<J | j	d ksCJ | j
d ksJJ | jd ksQJ | jd ksXJ | jd ks_J | jdksfJ | jdksmJ | jdkstJ | jdks{J | jd ksJ | jd ksJ | jd ksJ | jdksJ | jdksJ | jdksJ | jdksJ | jdksJ | jdksJ | jd ksJ | jdksJ d S )Nr   )r7   r5   nameversion	platformssupported_platformssummarydescriptionkeywords	home_pagedownload_urlauthorauthor_emaillicenseclassifiersrequiresprovides	obsoletes
maintainermaintainer_emailrequires_pythonrequires_externalrequires_distprovides_distobsoletes_distproject_urlsprovides_extrasdescription_content_typedynamic)sdistr   r   r   test_distribution_ctor_defaults   s:   rT   c                  C   @   t d } tt |   W d    d S 1 sw   Y  d S N)r7   pytestraisesNotImplementedErrorextractMetadatar6   r   r   r   <test_distribution_extractMetadata_raises_NotImplementedError      
"r\   c                  C   rU   rV   )r7   rW   rX   rY   readr[   r   r   r   1test_distribution_read_raises_NotImplementedError   r]   r_   c                  C   s&   ddl m}  t }| | ksJ d S )Nr   HEADER_ATTRS_1_0)r   ra   r7   _getHeaderAttrsra   r6   r   r   r   %test_distribution__getHeaderAttrs_hit   s   rd   c                  C   s   ddl m}  d}t|}tjdd}| dksJ W d    n1 s%w   Y  t|dks2J |d j| u s;J |t|d j	v sFJ d S )Nr   UnknownMetadataVersionnonesuchTrecordr      )
r   rf   r7   warningscatch_warningsrb   lencategorystrmessage)rf   NONESUCHr6   warnedr   r   r   .test_distribution__getHeaderAttrs_miss_unknown   s   rs   c                  C   s   ddl m}  ddl m} ddl m} d}t|}tjdd}| | | ks)J W d    n1 s3w   Y  t|dks@J |d j	|u sIJ |t
|d jv sTJ d S )	Nr   )HEADER_ATTRS)MAX_METADATA_VERSION_STR)NewMetadataVersionz99.99Trh   rj   )r   rt   ru   rv   r7   rk   rl   rb   rm   rn   ro   rp   )rt   ru   rv   HIGH_VERSIONr6   rr   r   r   r   *test_distribution__getHeaderAttrs_miss_new   s   rx   c                  C   s   t  } | d d S )Nz'Metadata-Version: 1.0
Name: lp722928_c3)r7   parser[   r   r   r   %test_distribution_parse_given_unicode   s   rz   c                  C   J   ddl m}  td }|d |jdksJ t|dd | D ks#J d S )Nr   r`   Metadata-Version: 1.0r3   c                 S      g | ]}|d  qS rj   r   .0xr   r   r   
<listcomp>       z@test_distribution_parse_Metadata_Version_1_0.<locals>.<listcomp>)r   ra   r7   ry   r5   listrc   r   r   r   ,test_distribution_parse_Metadata_Version_1_0   
   
r   c                  C   r{   )Nr   )HEADER_ATTRS_1_1zMetadata-Version: 1.11.1c                 S   r}   r~   r   r   r   r   r   r      r   z@test_distribution_parse_Metadata_Version_1_1.<locals>.<listcomp>)r   r   r7   ry   r5   r   )r   r6   r   r   r   ,test_distribution_parse_Metadata_Version_1_1   r   r   c                  C   r{   )Nr   )HEADER_ATTRS_1_2zMetadata-Version: 1.21.2c                 S   r}   r~   r   r   r   r   r   r     r   z@test_distribution_parse_Metadata_Version_1_2.<locals>.<listcomp>)r   r   r7   ry   r5   r   )r   r6   r   r   r   ,test_distribution_parse_Metadata_Version_1_2   r   r   c                  C   r{   )Nr   )HEADER_ATTRS_2_1zMetadata-Version: 2.12.1c                 S   r}   r~   r   r   r   r   r   r     r   z@test_distribution_parse_Metadata_Version_2_1.<locals>.<listcomp>)r   r   r7   ry   r5   r   )r   r6   r   r   r   ,test_distribution_parse_Metadata_Version_2_1  r   r   c                  C   r{   )Nr   )HEADER_ATTRS_2_2zMetadata-Version: 2.22.2c                 S   r}   r~   r   r   r   r   r   r     r   z@test_distribution_parse_Metadata_Version_2_2.<locals>.<listcomp>)r   r   r7   ry   r5   r   )r   r6   r   r   r   ,test_distribution_parse_Metadata_Version_2_2
  r   r   c                  C   r{   )Nr   )HEADER_ATTRS_2_3zMetadata-Version: 2.3z2.3c                 S   r}   r~   r   r   r   r   r   r     r   z@test_distribution_parse_Metadata_Version_2_3.<locals>.<listcomp>)r   r   r7   ry   r5   r   )r   r6   r   r   r   ,test_distribution_parse_Metadata_Version_2_3  r   r   c                  C   s   ddl m}  td }tjdd}|d t|g ksJ W d    n1 s(w   Y  |jdks4J t|dks<J |d j	| u sEJ dt
|d jv sPJ d S )Nr   re   Trh   zMetadata-Version: 1.3z1.3rj   )r   rf   r7   rk   rl   ry   r   r5   rm   rn   ro   rp   )rf   r6   rr   r   r   r   0test_distribution_parse_Metadata_Version_unknown  s   
r   c                  C   s$   t d} | d | jdksJ d S )Nr   r|   )r7   ry   r5   r[   r   r   r   1test_distribution_parse_Metadata_Version_override'     
r   c                  C   "   t  } | d | jdksJ d S )NzName: foobarfoobar)r7   ry   r8   r[   r   r   r   test_distribution_parse_Name,     
r   c                  C   r   )NzVersion: 2.1.3b5z2.1.3b5)r7   ry   r9   r[   r   r   r   test_distribution_parse_Version1  r   r   c                  C   (   t  } | d t| jdgksJ d S )NzPlatform: Plan9Plan9r7   ry   r   r:   r[   r   r   r   'test_distribution_parse_Platform_single6     
r   c                  C   *   t  } | d t| jddgksJ d S )NzPlatform: Plan9
Platform: AIXr   AIXr   r[   r   r   r   )test_distribution_parse_Platform_multiple;  s   
r   c                  C   r   )NzSupported-Platform: Plan9r   r7   ry   r   r;   r[   r   r   r   1test_distribution_parse_Supported_Platform_single@  r   r   c                  C   r   )Nz=Supported-Platform: i386-win32
Supported-Platform: RedHat 7.2z
i386-win32z
RedHat 7.2r   r[   r   r   r   3test_distribution_parse_Supported_Platform_multipleE  s   
r   c                  C   r   )NzSummary: Package for foozPackage for foo)r7   ry   r<   r[   r   r   r   test_distribution_parse_SummaryK  r   r   c                  C   r   )Nz?Description: This package enables integration with foo servers.z2This package enables integration with foo servers.r7   ry   r=   r[   r   r   r   #test_distribution_parse_DescriptionP  s   r   c                  C   r   )NzGDescription: This package enables integration with
        foo servers.2This package enables integration with
foo servers.r   r[   r   r   r   -test_distribution_parse_Description_multilineZ  s   r   c                  C   r   )Nz<Foo: Bar

This package enables integration with
foo servers.r   r   r[   r   r   r   .test_distribution_parse_Description_in_payloade  s   r   c                  C   r   )NzKeywords: bar foo quxzbar foo qux)r7   ry   r>   r[   r   r   r    test_distribution_parse_Keywordsr  r   r   c                  C   r   )Nz%Home-page: http://example.com/packagezhttp://example.com/package)r7   ry   r?   r[   r   r   r   !test_distribution_parse_Home_pagew  r   r   c                  C   r   )NzAuthor: J. Phredd BloggsJ. Phredd Bloggs)r7   ry   rA   r[   r   r   r   test_distribution_parse_Author|  r   r   c                  C   r   )Nz!Author-email: phreddy@example.comphreddy@example.com)r7   ry   rB   r[   r   r   r   $test_distribution_parse_Author_Email  r   r   c                  C   r   )NzLicense: PoeticPoetic)r7   ry   rC   r[   r   r   r   test_distribution_parse_License  r   r   c                  C   *   t d} | d t| jdgksJ d S )Nr   zClassifier: Some :: Silly ThingSome :: Silly Thingr7   ry   r   rD   r[   r   r   r   )test_distribution_parse_Classifier_single     
r   c                  C   ,   t d} | d t| jddgksJ d S )Nr   z7Classifier: Some :: Silly Thing
Classifier: Or :: Otherr   zOr :: Otherr   r[   r   r   r   +test_distribution_parse_Classifier_multiple     
r   c                  C   $   t d} | d | jdksJ d S )Nr   z:Download-URL: http://example.com/package/mypackage-0.1.zipz,http://example.com/package/mypackage-0.1.zip)r7   ry   r@   r[   r   r   r   $test_distribution_parse_Download_URL  s   
r   c                  C   r   )Nr   zRequires: SpanishInquisitionSpanishInquisitionr7   ry   r   rE   r[   r   r   r   2test_distribution_parse_Requires_single_wo_version  r   r   c                  C   r   )Nr   z$Requires: SpanishInquisition (>=1.3)SpanishInquisition (>=1.3)r   r[   r   r   r   1test_distribution_parse_Requires_single_w_version  r   r   c                  C   ,   t d} | d t| jg dksJ d S )Nr   zWRequires: SpanishInquisition
Requires: SillyWalks (1.4)
Requires: kniggits (>=2.3,<3.0))r   SillyWalks (1.4)kniggits (>=2.3,<3.0)r   r[   r   r   r   )test_distribution_parse_Requires_multiple     
r   c                  C   r   )Nr   zProvides: SillyWalks
SillyWalksr7   ry   r   rF   r[   r   r   r   2test_distribution_parse_Provides_single_wo_version  r   r   c                  C   r   )Nr   zProvides: SillyWalks (1.4)r   r   r[   r   r   r   1test_distribution_parse_Provides_single_w_version  r   r   c                  C   r   )Nr   z1Provides: SillyWalks
Provides: DeadlyJoke (3.1.4)r   DeadlyJoke (3.1.4)r   r[   r   r   r   )test_distribution_parse_Provides_multiple  r   r   c                  C   r   )Nr   zObsoletes: SillyWalksr   r7   ry   r   rG   r[   r   r   r   3test_distribution_parse_Obsoletes_single_no_version  r   r   c                  C   r   )Nr   zObsoletes: SillyWalks (<=1.3)SillyWalks (<=1.3)r   r[   r   r   r   2test_distribution_parse_Obsoletes_single_w_version  r   r   c                  C   r   )Nr   z1Obsoletes: kniggits
Obsoletes: SillyWalks (<=2.0)kniggitszSillyWalks (<=2.0)r   r[   r   r   r   *test_distribution_parse_Obsoletes_multiple  r   r   c                  C   &   t dd} | d | jdksJ d S )Nr   r5   zMaintainer: J. Phredd Bloggsr   )r7   ry   rH   r[   r   r   r   "test_distribution_parse_Maintainer     

r   c                  C   r   )Nr   r   z%Maintainer-email: phreddy@example.comr   )r7   ry   rI   r[   r   r   r   (test_distribution_parse_Maintainer_Email  r   r   c                  C   r   )Nr   zRequires-Python: >2.4z>2.4)r7   ry   rJ   r[   r   r   r   3test_distribution_parse_Requires_Python_single_spec  r   r   c                  C   r   )Nr   zRequires-External: libfoolibfoor7   ry   r   rK   r[   r   r   r   ;test_distribution_parse_Requires_External_single_wo_version  r   r   c                  C   r   )Nr   z!Requires-External: libfoo (>=1.3)zlibfoo (>=1.3)r   r[   r   r   r   :test_distribution_parse_Requires_External_single_w_version  r   r   c                  C   r   )Nr   z`Requires-External: libfoo
Requires-External: libbar (1.4)
Requires-External: libbaz (>=2.3,<3.0))r   zlibbar (1.4)zlibbaz (>=2.3,<3.0)r   r[   r   r   r   2test_distribution_parse_Requires_External_multiple  r   r   c                  C   r   )Nr   z!Requires-Dist: SpanishInquisitionr   r7   ry   r   rL   r[   r   r   r   7test_distribution_parse_Requires_Dist_single_wo_version  r   r   c                  C   r   )Nr   z)Requires-Dist: SpanishInquisition (>=1.3)r   r   r[   r   r   r   6test_distribution_parse_Requires_Dist_single_w_version  r   r   c                  C   r   )Nr   z:Requires-Dist: SpanishInquisition; python_version == '1.4'z+SpanishInquisition; python_version == '1.4'r   r[   r   r   r   9test_distribution_parse_Requires_Dist_single_w_env_marker  s
   
r   c                  C   r   )Nr   zyRequires-Dist: SpanishInquisition
Requires-Dist: SillyWalks; python_version == '1.4'
Requires-Dist: kniggits (>=2.3,<3.0))r   z#SillyWalks; python_version == '1.4'r   r   r[   r   r   r   .test_distribution_parse_Requires_Dist_multiple  r   r   c                  C   r   )Nr   zProvides-Dist: SillyWalksr   r7   ry   r   rM   r[   r   r   r   7test_distribution_parse_Provides_Dist_single_wo_version  r   r   c                  C   r   )Nr   zProvides-Dist: SillyWalks (1.4)r   r   r[   r   r   r   6test_distribution_parse_Provides_Dist_single_w_version"  r   r   c                  C   r   )Nr   z0Provides-Dist: SillyWalks; sys.platform == 'os2'!SillyWalks; sys.platform == 'os2'r   r[   r   r   r   9test_distribution_parse_Provides_Dist_single_w_env_marker'  r   r   c                  C   r   )Nr   ztProvides-Dist: SillyWalks
Provides-Dist: SpanishInquisition; sys.platform == 'os2'
Provides-Dist: DeadlyJoke (3.1.4))r   z)SpanishInquisition; sys.platform == 'os2'r   r   r[   r   r   r   .test_distribution_parse_Provides_Dist_multiple,  r   r   c                  C   r   )Nr   zObsoletes-Dist: SillyWalksr   r7   ry   r   rN   r[   r   r   r   8test_distribution_parse_Obsoletes_Dist_single_no_version9  r   r   c                  C   r   )Nr   z"Obsoletes-Dist: SillyWalks (<=1.3)r   r   r[   r   r   r   7test_distribution_parse_Obsoletes_Dist_single_w_version>  r   r   c                  C   r   )Nr   z1Obsoletes-Dist: SillyWalks; sys.platform == 'os2'r   r   r[   r   r   r   :test_distribution_parse_Obsoletes_Dist_single_w_env_markerC  r   r   c                  C   r   )Nr   znObsoletes-Dist: kniggits
Obsoletes-Dist: SillyWalks; sys.platform == 'os2'
Obsoletes-Dist: DeadlyJoke (<=2.0)
)r   r   zDeadlyJoke (<=2.0)r   r[   r   r   r   /test_distribution_parse_Obsoletes_Dist_multipleH  s   
r   c                  C   r   )Nr   z7Project-URL: Bug tracker, http://bugs.example.com/grail*Bug tracker, http://bugs.example.com/grailr7   ry   r   rO   r[   r   r   r   5test_distribution_parse_Project_URL_single_no_versionV  s
   
r   c                  C   r   )Nr   zmProject-URL: Bug tracker, http://bugs.example.com/grail
Project-URL: Repository, http://svn.example.com/grailr   z(Repository, http://svn.example.com/grailr   r[   r   r   r   ,test_distribution_parse_Project_URL_multiple^  s   
r   c                  C   r   )Nr   zProvides-Extra: pdfpdfr7   ry   r   rP   r[   r   r   r   -test_distribution_parse_Provides_Extra_singlej  r   r   c                  C   r   )Nr   z'Provides-Extra: pdf
Provides-Extra: texr   texr   r[   r   r   r   /test_distribution_parse_Provides_Extra_multipleo  r   r   c                  C   r   )Nr   z$Description-Content-Type: text/plainz
text/plain)r7   ry   rQ   r[   r   r   r   8test_distribution_parse_Distribution_Content_Type_singleu  r   r   c                  C   r   )Nr   zDynamic: Platforms	Platformsr7   ry   r   rR   r[   r   r   r   &test_distribution_parse_Dynamic_single{  r   r   c                  C   r   )Nr   z/Dynamic: Platforms
Dynamic: Supported-Platformsr   zSupported-Platformsr   r[   r   r   r   (test_distribution_parse_Dynamic_multiple  r   r   c                  C   r   )N2.4zLicense-Expression: MITMIT)r7   ry   license_expressionr[   r   r   r   1test_distribution_parse_License_Expression_single  r   r  c                  C   r   )Nr   zLicense-File: LICENSE.txtLICENSE.txtr7   ry   r   license_filer[   r   r   r   +test_distribution_parse_License_File_single  r   r  c                  C   r   )Nr   z8License-File: LICENSE.txt
License-File: docs/LICENSE.rstr  zdocs/LICENSE.rstr  r[   r   r   r   -test_distribution_parse_License_File_multiple  r   r  )r3   )Vrk   rW   r   r   r   r   r   r#   r%   r)   r*   r.   r/   r1   r2   r7   rT   r\   r_   rd   rs   rx   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r   r   <module>   s    

$
	