B
    {[?A  ã               @   s   d dl Z G dd„ de jƒZdS )é    Nc               @   sæ  e Zd Zdd„ Zdyd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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d0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Zd<d=„ Z d>d?„ Z!d@dA„ Z"dBdC„ Z#dDdE„ Z$dFdG„ Z%dHdI„ Z&dJdK„ Z'dLdM„ Z(dNdO„ Z)dPdQ„ Z*dRdS„ Z+dTdU„ Z,dVdW„ Z-dXdY„ Z.dZd[„ Z/d\d]„ Z0d^d_„ Z1d`da„ Z2dbdc„ Z3ddde„ Z4dfdg„ Z5dhdi„ Z6djdk„ Z7dldm„ Z8dndo„ Z9dpdq„ Z:drds„ Z;dtdu„ Z<dvdw„ Z=dxS )zÚDistributionTestsc             C   s   ddl m} |S )Nr   )ÚDistribution)Úpkginfo.distributionr   )Úselfr   © r   ú>lib/python3.7/site-packages/pkginfo/tests/test_distribution.pyÚ_getTargetClass   s    z!DistributionTests._getTargetClassú1.0c             C   s   |   ¡ ƒ }|d k	r||_|S )N)r   Úmetadata_version)r   r
   Údistr   r   r   Ú_makeOne	   s    
zDistributionTests._makeOnec             C   sl  |   d ¡}|  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd¡ |  |jd¡ |  |jd ¡ |  |jd ¡ |  |j	d ¡ |  |j
d ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ d S )Nr   )r   ÚassertEqualr
   Ú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)r   Zsdistr   r   r   Útest_ctor_defaults   s4    
z$DistributionTests.test_ctor_defaultsc             C   s   |   d ¡}|  t|j¡ d S )N)r   ÚassertRaisesÚNotImplementedErrorZextractMetadata)r   r   r   r   r   Ú/test_extractMetadata_raises_NotImplementedError+   s    
zADistributionTests.test_extractMetadata_raises_NotImplementedErrorc             C   s   |   d ¡}|  t|j¡ d S )N)r   r'   r(   Úread)r   r   r   r   r   Ú$test_read_raises_NotImplementedError0   s    
z6DistributionTests.test_read_raises_NotImplementedErrorc             C   sL   ddl m} |  d ¡}| d¡ |  |jd¡ |  t|ƒdd„ |D ƒ¡ d S )Nr   )ÚHEADER_ATTRS_1_0zMetadata-Version: 1.0z1.0c             S   s   g | ]}|d  ‘qS )é   r   )Ú.0Úxr   r   r   ú
<listcomp>;   s    zEDistributionTests.test_parse_Metadata_Version_1_0.<locals>.<listcomp>)r   r,   r   Úparser   r
   Úlist)r   r,   r   r   r   r   Útest_parse_Metadata_Version_1_05   s    


z1DistributionTests.test_parse_Metadata_Version_1_0c             C   sL   ddl m} |  d ¡}| d¡ |  |jd¡ |  t|ƒdd„ |D ƒ¡ d S )Nr   )ÚHEADER_ATTRS_1_1zMetadata-Version: 1.1z1.1c             S   s   g | ]}|d  ‘qS )r-   r   )r.   r/   r   r   r   r0   C   s    zEDistributionTests.test_parse_Metadata_Version_1_1.<locals>.<listcomp>)r   r4   r   r1   r   r
   r2   )r   r4   r   r   r   r   Útest_parse_Metadata_Version_1_1=   s    


z1DistributionTests.test_parse_Metadata_Version_1_1c             C   sL   ddl m} |  d ¡}| d¡ |  |jd¡ |  t|ƒdd„ |D ƒ¡ d S )Nr   )ÚHEADER_ATTRS_1_2zMetadata-Version: 1.2z1.2c             S   s   g | ]}|d  ‘qS )r-   r   )r.   r/   r   r   r   r0   K   s    zEDistributionTests.test_parse_Metadata_Version_1_2.<locals>.<listcomp>)r   r6   r   r1   r   r
   r2   )r   r6   r   r   r   r   Útest_parse_Metadata_Version_1_2E   s    


z1DistributionTests.test_parse_Metadata_Version_1_2c             C   sL   ddl m} |  d ¡}| d¡ |  |jd¡ |  t|ƒdd„ |D ƒ¡ d S )Nr   )ÚHEADER_ATTRS_2_1zMetadata-Version: 2.1z2.1c             S   s   g | ]}|d  ‘qS )r-   r   )r.   r/   r   r   r   r0   S   s    zEDistributionTests.test_parse_Metadata_Version_2_1.<locals>.<listcomp>)r   r8   r   r1   r   r
   r2   )r   r8   r   r   r   r   Útest_parse_Metadata_Version_2_1M   s    


z1DistributionTests.test_parse_Metadata_Version_2_1c             C   s6   |   d ¡}| d¡ |  |jd¡ |  t|ƒg ¡ d S )NzMetadata-Version: 1.3z1.3)r   r1   r   r
   r2   )r   r   r   r   r   Ú#test_parse_Metadata_Version_unknownU   s    

z5DistributionTests.test_parse_Metadata_Version_unknownc             C   s&   |   d¡}| d¡ |  |jd¡ d S )Nz1.2zMetadata-Version: 1.0)r   r1   r   r
   )r   r   r   r   r   Ú$test_parse_Metadata_Version_override[   s    

z6DistributionTests.test_parse_Metadata_Version_overridec             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzName: foobarZfoobar)r   r1   r   r   )r   r   r   r   r   Útest_parse_Name`   s    
z!DistributionTests.test_parse_Namec             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzVersion: 2.1.3b5z2.1.3b5)r   r1   r   r   )r   r   r   r   r   Útest_parse_Versione   s    
z$DistributionTests.test_parse_Versionc             C   s*   |   ¡ }| d¡ |  t|jƒdg¡ d S )NzPlatform: Plan9ÚPlan9)r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Platform_singlej   s    
z,DistributionTests.test_parse_Platform_singlec             C   s,   |   ¡ }| d¡ |  t|jƒddg¡ d S )NzPlatform: Plan9
Platform: AIXr>   ZAIX)r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Platform_multipleo   s    
z.DistributionTests.test_parse_Platform_multiplec             C   s*   |   ¡ }| d¡ |  t|jƒdg¡ d S )NzSupported-Platform: Plan9r>   )r   r1   r   r2   r   )r   r   r   r   r   Ú$test_parse_Supported_Platform_singlet   s    
z6DistributionTests.test_parse_Supported_Platform_singlec             C   s,   |   ¡ }| d¡ |  t|jƒddg¡ d S )Nz=Supported-Platform: i386-win32
Supported-Platform: RedHat 7.2z
i386-win32z
RedHat 7.2)r   r1   r   r2   r   )r   r   r   r   r   Ú&test_parse_Supported_Platform_multipley   s    
z8DistributionTests.test_parse_Supported_Platform_multiplec             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzSummary: Package for foozPackage for foo)r   r1   r   r   )r   r   r   r   r   Útest_parse_Summary€   s    
z$DistributionTests.test_parse_Summaryc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )Nz?Description: This package enables integration with foo servers.z2This package enables integration with foo servers.)r   r1   r   r   )r   r   r   r   r   Útest_parse_Description…   s    
z(DistributionTests.test_parse_Descriptionc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzGDescription: This package enables integration with
        foo servers.z2This package enables integration with
foo servers.)r   r1   r   r   )r   r   r   r   r   Ú test_parse_Description_multiline   s    
z2DistributionTests.test_parse_Description_multilinec             C   s$   |   ¡ }| d¡ |  |jd¡ d S )Nz<Foo: Bar

This package enables integration with
foo servers.z2This package enables integration with
foo servers.)r   r1   r   r   )r   r   r   r   r   Ú!test_parse_Description_in_payload•   s    
z3DistributionTests.test_parse_Description_in_payloadc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzKeywords: bar foo quxzbar foo qux)r   r1   r   r   )r   r   r   r   r   Útest_parse_KeywordsŸ   s    
z%DistributionTests.test_parse_Keywordsc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )Nz%Home-page: http://example.com/packagezhttp://example.com/package)r   r1   r   r   )r   r   r   r   r   Útest_parse_Home_page¤   s    
z&DistributionTests.test_parse_Home_pagec             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzAuthor: J. Phredd BloggszJ. Phredd Bloggs)r   r1   r   r   )r   r   r   r   r   Útest_parse_Author©   s    
z#DistributionTests.test_parse_Authorc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )Nz!Author-email: phreddy@example.comzphreddy@example.com)r   r1   r   r   )r   r   r   r   r   Útest_parse_Author_Email®   s    
z)DistributionTests.test_parse_Author_Emailc             C   s$   |   ¡ }| d¡ |  |jd¡ d S )NzLicense: PoeticZPoetic)r   r1   r   r   )r   r   r   r   r   Útest_parse_License³   s    
z$DistributionTests.test_parse_Licensec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zClassifier: Some :: Silly ThingzSome :: Silly Thing)r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Classifier_single¹   s    

z.DistributionTests.test_parse_Classifier_singlec             C   s.   |   d¡}| d¡ |  t|jƒddg¡ d S )Nz1.1z7Classifier: Some :: Silly Thing
Classifier: Or :: OtherzSome :: Silly ThingzOr :: Other)r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Classifier_multiple¾   s    

z0DistributionTests.test_parse_Classifier_multiplec             C   s&   |   d¡}| d¡ |  |jd¡ d S )Nz1.1z:Download-URL: http://example.com/package/mypackage-0.1.zipz,http://example.com/package/mypackage-0.1.zip)r   r1   r   r   )r   r   r   r   r   Útest_parse_Download_URLÅ   s    

z)DistributionTests.test_parse_Download_URLc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zRequires: SpanishInquisitionÚSpanishInquisition)r   r1   r   r2   r   )r   r   r   r   r   Ú%test_parse_Requires_single_wo_versionÌ   s    

z7DistributionTests.test_parse_Requires_single_wo_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1z$Requires: SpanishInquisition (>=1.3)zSpanishInquisition (>=1.3))r   r1   r   r2   r   )r   r   r   r   r   Ú$test_parse_Requires_single_w_versionÑ   s    

z6DistributionTests.test_parse_Requires_single_w_versionc             C   s0   |   d¡}| d¡ |  t|jƒdddg¡ d S )Nz1.1zWRequires: SpanishInquisition
Requires: SillyWalks (1.4)
Requires: kniggits (>=2.3,<3.0)rO   zSillyWalks (1.4)zkniggits (>=2.3,<3.0))r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Requires_multipleÖ   s    

z.DistributionTests.test_parse_Requires_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zProvides: SillyWalksÚ
SillyWalks)r   r1   r   r2   r   )r   r   r   r   r   Ú%test_parse_Provides_single_wo_versioná   s    

z7DistributionTests.test_parse_Provides_single_wo_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zProvides: SillyWalks (1.4)zSillyWalks (1.4))r   r1   r   r2   r   )r   r   r   r   r   Ú$test_parse_Provides_single_w_versionæ   s    

z6DistributionTests.test_parse_Provides_single_w_versionc             C   s.   |   d¡}| d¡ |  t|jƒddg¡ d S )Nz1.1z1Provides: SillyWalks
Provides: DeadlyJoke (3.1.4)rS   zDeadlyJoke (3.1.4))r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Provides_multipleë   s
    

z.DistributionTests.test_parse_Provides_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zObsoletes: SillyWalksrS   )r   r1   r   r2   r   )r   r   r   r   r   Ú&test_parse_Obsoletes_single_no_versionô   s    

z8DistributionTests.test_parse_Obsoletes_single_no_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.1zObsoletes: SillyWalks (<=1.3)zSillyWalks (<=1.3))r   r1   r   r2   r   )r   r   r   r   r   Ú%test_parse_Obsoletes_single_w_versionù   s    

z7DistributionTests.test_parse_Obsoletes_single_w_versionc             C   s.   |   d¡}| d¡ |  t|jƒddg¡ d S )Nz1.1z1Obsoletes: kniggits
Obsoletes: SillyWalks (<=2.0)ÚkniggitszSillyWalks (<=2.0))r   r1   r   r2   r   )r   r   r   r   r   Útest_parse_Obsoletes_multipleþ   s
    

z/DistributionTests.test_parse_Obsoletes_multiplec             C   s(   | j dd}| d¡ |  |jd¡ d S )Nz1.2)r
   zMaintainer: J. Phredd BloggszJ. Phredd Bloggs)r   r1   r   r   )r   r   r   r   r   Útest_parse_Maintainer	  s    
z'DistributionTests.test_parse_Maintainerc             C   s(   | j dd}| d¡ |  |jd¡ d S )Nz1.2)r
   z%Maintainer-email: phreddy@example.comzphreddy@example.com)r   r1   r   r   )r   r   r   r   r   Útest_parse_Maintainer_Email  s    
z-DistributionTests.test_parse_Maintainer_Emailc             C   s&   |   d¡}| d¡ |  |jd¡ d S )Nz1.2zRequires-Python: >2.4z>2.4)r   r1   r   r    )r   r   r   r   r   Ú&test_parse_Requires_Python_single_spec  s    

z8DistributionTests.test_parse_Requires_Python_single_specc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2zRequires-External: libfooÚlibfoo)r   r1   r   r2   r!   )r   r   r   r   r   Ú.test_parse_Requires_External_single_wo_version  s    

z@DistributionTests.test_parse_Requires_External_single_wo_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z!Requires-External: libfoo (>=1.3)zlibfoo (>=1.3))r   r1   r   r2   r!   )r   r   r   r   r   Ú-test_parse_Requires_External_single_w_version  s    

z?DistributionTests.test_parse_Requires_External_single_w_versionc             C   s0   |   d¡}| d¡ |  t|jƒdddg¡ d S )Nz1.2z`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   r1   r   r2   r!   )r   r   r   r   r   Ú%test_parse_Requires_External_multiple"  s    

z7DistributionTests.test_parse_Requires_External_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z!Requires-Dist: SpanishInquisitionrO   )r   r1   r   r2   r"   )r   r   r   r   r   Ú*test_parse_Requires_Dist_single_wo_version.  s    

z<DistributionTests.test_parse_Requires_Dist_single_wo_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z)Requires-Dist: SpanishInquisition (>=1.3)zSpanishInquisition (>=1.3))r   r1   r   r2   r"   )r   r   r   r   r   Ú)test_parse_Requires_Dist_single_w_version3  s    

z;DistributionTests.test_parse_Requires_Dist_single_w_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z:Requires-Dist: SpanishInquisition; python_version == '1.4'z+SpanishInquisition; python_version == '1.4')r   r1   r   r2   r"   )r   r   r   r   r   Ú,test_parse_Requires_Dist_single_w_env_marker9  s    

z>DistributionTests.test_parse_Requires_Dist_single_w_env_markerc             C   s0   |   d¡}| d¡ |  t|jƒdddg¡ d S )Nz1.2zyRequires-Dist: SpanishInquisition
Requires-Dist: SillyWalks; python_version == '1.4'
Requires-Dist: kniggits (>=2.3,<3.0)rO   z#SillyWalks; python_version == '1.4'zkniggits (>=2.3,<3.0))r   r1   r   r2   r"   )r   r   r   r   r   Ú!test_parse_Requires_Dist_multiple@  s    

z3DistributionTests.test_parse_Requires_Dist_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2zProvides-Dist: SillyWalksrS   )r   r1   r   r2   r#   )r   r   r   r   r   Ú*test_parse_Provides_Dist_single_wo_versionK  s    

z<DistributionTests.test_parse_Provides_Dist_single_wo_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2zProvides-Dist: SillyWalks (1.4)zSillyWalks (1.4))r   r1   r   r2   r#   )r   r   r   r   r   Ú)test_parse_Provides_Dist_single_w_versionP  s    

z;DistributionTests.test_parse_Provides_Dist_single_w_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z0Provides-Dist: SillyWalks; sys.platform == 'os2'z!SillyWalks; sys.platform == 'os2')r   r1   r   r2   r#   )r   r   r   r   r   Ú,test_parse_Provides_Dist_single_w_env_markerU  s    

z>DistributionTests.test_parse_Provides_Dist_single_w_env_markerc             C   s0   |   d¡}| d¡ |  t|jƒdddg¡ d S )Nz1.2ztProvides-Dist: SillyWalks
Provides-Dist: SpanishInquisition; sys.platform == 'os2'
Provides-Dist: DeadlyJoke (3.1.4)rS   z)SpanishInquisition; sys.platform == 'os2'zDeadlyJoke (3.1.4))r   r1   r   r2   r#   )r   r   r   r   r   Ú!test_parse_Provides_Dist_multiple[  s    

z3DistributionTests.test_parse_Provides_Dist_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2zObsoletes-Dist: SillyWalksrS   )r   r1   r   r2   r$   )r   r   r   r   r   Ú+test_parse_Obsoletes_Dist_single_no_versionf  s    

z=DistributionTests.test_parse_Obsoletes_Dist_single_no_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z"Obsoletes-Dist: SillyWalks (<=1.3)zSillyWalks (<=1.3))r   r1   r   r2   r$   )r   r   r   r   r   Ú*test_parse_Obsoletes_Dist_single_w_versionk  s    

z<DistributionTests.test_parse_Obsoletes_Dist_single_w_versionc             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z1Obsoletes-Dist: SillyWalks; sys.platform == 'os2'z!SillyWalks; sys.platform == 'os2')r   r1   r   r2   r$   )r   r   r   r   r   Ú-test_parse_Obsoletes_Dist_single_w_env_markerp  s    

z?DistributionTests.test_parse_Obsoletes_Dist_single_w_env_markerc             C   s0   |   d¡}| d¡ |  t|jƒdddg¡ d S )Nz1.2znObsoletes-Dist: kniggits
Obsoletes-Dist: SillyWalks; sys.platform == 'os2'
Obsoletes-Dist: DeadlyJoke (<=2.0)
rY   z!SillyWalks; sys.platform == 'os2'zDeadlyJoke (<=2.0))r   r1   r   r2   r$   )r   r   r   r   r   Ú"test_parse_Obsoletes_Dist_multiplev  s    

z4DistributionTests.test_parse_Obsoletes_Dist_multiplec             C   s,   |   d¡}| d¡ |  t|jƒdg¡ d S )Nz1.2z7Project-URL: Bug tracker, http://bugs.example.com/grailz*Bug tracker, http://bugs.example.com/grail)r   r1   r   r2   r%   )r   r   r   r   r   Ú(test_parse_Project_URL_single_no_version‚  s    

z:DistributionTests.test_parse_Project_URL_single_no_versionc             C   s.   |   d¡}| d¡ |  t|jƒddg¡ d S )Nz1.2zmProject-URL: Bug tracker, http://bugs.example.com/grail
Project-URL: Repository, http://svn.example.com/grailz*Bug tracker, http://bugs.example.com/grailz(Repository, http://svn.example.com/grail)r   r1   r   r2   r%   )r   r   r   r   r   Útest_parse_Project_URL_multipleˆ  s
    

z1DistributionTests.test_parse_Project_URL_multiplec             C   s&   ddl m} |  ¡ }| |dƒ¡ d S )Nr   )Úuz'Metadata-Version: 1.0
Name: lp722928_c3)Zpkginfo._compatrp   r   r1   )r   rp   r   r   r   r   Útest_parse_given_unicode‘  s    z*DistributionTests.test_parse_given_unicodeN)r	   )>Ú__name__Ú
__module__Ú__qualname__r   r   r&   r)   r+   r3   r5   r7   r9   r:   r;   r<   r=   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rP   rQ   rR   rT   rU   rV   rW   rX   rZ   r[   r\   r]   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rq   r   r   r   r   r      sv   

		r   )ZunittestZTestCaser   r   r   r   r   Ú<module>   s   