o
    LK&h                     @  s   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlZd dlmZ d dlmZ d dlmZmZmZ d dlmZ d	d
lmZmZ d	dlmZ G dd deZejdd Z G dd dZ!G dd dZ"dS )    )annotationsN)Path)mock)path)errors)egg_infomanifest_makerwrite_entries)Distribution   )contextsenvironment)DALSc                   @  s   e Zd ZdS )EnvironmentN)__name__
__module____qualname__ r   r   Q/var/www/html/venv/lib/python3.10/site-packages/setuptools/tests/test_egg_info.pyr      s    r   c               
   #  s    t jddE t } t tj d}t fdd|D | _t	t
tj| j  t| jd dtdjd	i | jii | V  W d    d S 1 sOw   Y  d S )
Nzsetuptools-test.)prefix)homelibscriptsdatazegg-basec                 3  s"    | ]}|t j |fV  qd S )N)osr   join).0dirnameenv_dirr   r   	<genexpr>"   s     zenv.<locals>.<genexpr>r   z.pydistutils.cfgzR
                [egg_info]
                egg-base = {egg-base}
                r   )r   tempdirr   r   chmodstatS_IRWXUdictpathslistmapmkdirvaluesr   buildr   format)envsubsr   r   r   r-      s(   
"r-   c                   @  sX  e Zd ZedZdd Zeddd	Zd
d Ze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ejd  dZd ejd  d!Zd"ZG d#d$ d$Zejd%d&d'd(d)d*d+d,d-d.d/eeed0d1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Zejd=ed>d?d@dAfedBd?d@dfedCd?d@dAfed>dDd?dEdAfej edFd?d@dAdGdHgdIdJ Z!ejdKedLdMdNdOdPdQgg fedRdMdNdOdPdQgg fedSdMdNdOdPgdQgfedTdMdNdOg dPdQgfedUdMdNdOdQgdPgfedVd?dWdPgdXgfedCd?d@dYgg fedZdDd?dEdYgg fedLd[dMdNd\dPdQgg fej d]dMd^d_d`dNdadbdcg dddegdfdHej edgdMdhdidPgdjgdkdHej edldMdWdPgg dmdHej edndMdodYdpidqdYdrgdsgdtdHgdudv Z"ejdKedwdMdNdOg dPdQgfedxdMdNdOg dPdQgfedydMdzdNd{g d|g fed}dMdzdNd{g d|g fed~dMdzdNd{dPdQgdgfedyd?ddgdPdQgfedddMdzdNdg d|g fej eddMdhdidPgdjgdkdHej eddMd_d`ddPdgdgddHg	dd Z#dd Z$dd Z%dd Z&dd Z'dd Z(dd Z)dd Z*dd Z+dd Z,dd Z-dddZ.dd Z/dS )TestEggInfoz
        from setuptools import setup

        setup(
            name='foo',
            py_modules=['hello'],
            entry_points={'console_scripts': ['hi = hello.run']},
            zip_safe=False,
        )
        c                 C  s   t | jtdd d S )NzO
                def run():
                    print('hello')
                )setup.pyzhello.py)r   r+   setup_scriptr   )selfr   r   r   _create_project?   s   zTestEggInfo._create_projectpkg_info_lines	list[str]returntuple[int, int]c                 C  s6   | d  dd }tt| dd d \}}||fS )Nr    r   .   )splitr(   int)r4   version_strmajorminorr   r   r   _extract_mv_versionJ   s   zTestEggInfo._extract_mv_versionc           	      C  s   t j|jd d}t }t|}|  || t|ddd}|	 }W d   n1 s0w   Y  d|v s;J d|v sAJ d	|v sGJ d
}| 
|| dS )z
        When the egg_info section is empty or not present, running
        save_version_info should add the settings to the setup.cfg
        in a deterministic order.
        r   	setup.cfgrutf-8encodingN
[egg_info]tag_build =tag_date = 0	tag_buildtag_date)r   r   r   r&   r
   r   initialize_optionssave_version_infoopenread_validate_content_order	r2   
tmpdir_cwdr-   	setup_cfgdisteifcontentexpected_orderr   r   r   +test_egg_info_save_version_info_setup_emptyP   s   

z7TestEggInfo.test_egg_info_save_version_info_setup_emptyc                 C  s,   d |}tjtjB }t|| |sJ dS )zY
        Assert that the strings in expected appear in content
        in order.
        z.*N)r   re	MULTILINEDOTALLsearch)rW   expectedpatternflagsr   r   r   rP   j   s   
z#TestEggInfo._validate_content_orderc           	      C  s   t j|jd d}t|tdi t }t|}|  |	| t
|ddd}| }W d   n1 s9w   Y  d|v sDJ d	|v sJJ d
|v sPJ d}| || dS )z
        When running save_version_info on an existing setup.cfg
        with the 'default' values present from a previous run,
        the file should remain unchanged.
        r   rA   zU
            [egg_info]
            tag_build =
            tag_date = 0
            rB   rC   rD   NrF   rG   rH   rI   )r   r   r   r&   r+   r   r
   r   rL   rM   rN   rO   rP   rQ   r   r   r   .test_egg_info_save_version_info_setup_defaultst   s$   	

z:TestEggInfo.test_egg_info_save_version_info_setup_defaultsc                 C  s:   |    | || td}g d}t||ksJ d S )Nfoo.egg-info)PKG-INFOSOURCES.txtzdependency_links.txtentry_points.txtznot-zip-safeztop_level.txt)r3   _run_egg_info_commandr   listdirsorted)r2   rR   r-   actualr^   r   r   r   test_expected_files_produced   s
   
z(TestEggInfo.test_expected_files_producedc           	   
   C  s   t  }t|}tjdtdd}tjdd d}|F |+ dd l}d}tj|jj	|d |
  W d    n1 s;w   Y  W d    n1 sJw   Y  W d    d S W d    d S 1 sbw   Y  d S )	Nzos.utimeTEST)side_effectz+setuptools.command.egg_info.egg_info.mkpath)
return_valr   z,Cannot update time stamp of directory 'None'match)r
   r   r   patchOSErrordistutils.errorspytestraisesr   DistutilsFileErrorrun)	r2   rR   r-   rT   rU   utime_patchmkpath_patch	distutilsmsgr   r   r   test_handling_utime_error   s   
Pz%TestEggInfo.test_handling_utime_errorc                 C  sn   t d}t d}t||d tt}| || W d    n1 s&w   Y  d|jjd v s5J d S )Nzp
            [metadata]
            name=foo
            version=0.0.1
            license=file:MIT
            zK
            from setuptools import setup

            setup()
            r0   rA   
ValueErrorr   )	r   r   r+   rs   rt   AssertionErrorrf   valueargs)r2   rR   r-   setup_configr1   excr   r   r   test_license_is_a_string   s   	z$TestEggInfo.test_license_is_a_stringc                 C  sR   |    | || tjd}td | || tjd}||ks'J dS )z9Ensure timestamps are updated when the command is re-run.rb   gMbP?N)r3   rf   r   r   getmtimetimesleep)r2   rR   r-   timestamp_atimestamp_br   r   r   test_rebuilt   s   
zTestEggInfo.test_rebuiltc                 C  s   |    ttdddid | || tjdd}tj|d}t|dd	}d
| 	dv s6J W d    d S 1 sAw   Y  d S )Nz:
                recursive-include docs *.rst
            z	usage.rstzRun 'hi')MANIFEST.indocsr9   rb   rd   rC   rD   zdocs/usage.rst

r3   r   r+   r   rf   r   r   rN   rO   r;   )r2   rR   r-   egg_info_dirsources_txtrV   r   r   r   test_manifest_template_is_read   s   
"z*TestEggInfo.test_manifest_template_is_readFc                 C  s4   t d|rdn| }|r|nd}t||d d S )Nzi
            from setuptools import setup

            setup(name='foo', zip_safe=False, %s)
             r|   )r   r   r+   )r2   requiresuse_setup_cfgr1   r   r   r   r   _setup_script_with_requires   s   
z'TestEggInfo._setup_script_with_requireszpython_version<'r   'zpython_version < ""z<=>++c                   @  s   e Zd Zedd ZdS )zTestEggInfo.RequiresTestHelperc                    s   g }g }| D ]m}|  dd}|dd}t|dkr*|d  }t|}ni }|d  }	 fdd|D \}
}}|	|
df|	d	 |d
ffD ](\}}}|| d}|dre|dd  }t	j
j}|t	j|||||d qJqt	j
jd||dS )Nz

   r   r   r   c                   s    g | ]}t |jd i  qS )r   )r   r,   )r   aformat_dictr   r   
<listcomp>  s    z>TestEggInfo.RequiresTestHelper.parametrize.<locals>.<listcomp>F_in_setup_cfgTr   z@xfail
   )marks)r   r   expected_requiresinstall_cmd_kwargs)ids)lstripr;   poplenstripastliteral_evalappend
startswithrs   markxfailparamparametrize)	test_listr   idlist	argvaluestesttest_paramsname_kwargsvalr   namesetup_py_requiressetup_cfg_requiresr   id_r   use_cfgr   r   r   r   r     sH   


z*TestEggInfo.RequiresTestHelper.parametrizeN)r   r   r   staticmethodr   r   r   r   r   RequiresTestHelper  s    r   z
        install_requires_deterministic

        install_requires=["wheel>=0.5", "pytest"]

        [options]
        install_requires =
            wheel>=0.5
            pytest

        wheel>=0.5
        pytest
        z
        install_requires_ordered

        install_requires=["pytest>=3.0.2,!=10.9999"]

        [options]
        install_requires =
            pytest>=3.0.2,!=10.9999

        pytest!=10.9999,>=3.0.2
        z
        install_requires_with_marker

        install_requires=["barbazquux;{mismatch_marker}"],

        [options]
        install_requires =
            barbazquux; {mismatch_marker}

        [:{mismatch_marker_alternate}]
        barbazquux
        z
        install_requires_with_extra
        {'cmd': ['egg_info']}

        install_requires=["barbazquux [test]"],

        [options]
        install_requires =
            barbazquux [test]

        barbazquux[test]
        a  
        install_requires_with_extra_and_marker

        install_requires=["barbazquux [test]; {mismatch_marker}"],

        [options]
        install_requires =
            barbazquux [test]; {mismatch_marker}

        [:{mismatch_marker_alternate}]
        barbazquux[test]
        z
        setup_requires_with_markers

        setup_requires=["barbazquux;{mismatch_marker}"],

        [options]
        setup_requires =
            barbazquux; {mismatch_marker}

        z
        extras_require_with_extra
        {'cmd': ['egg_info']}

        extras_require={{"extra": ["barbazquux [test]"]}},

        [options.extras_require]
        extra = barbazquux [test]

        [extra]
        barbazquux[test]
        aF  
        extras_require_with_extra_and_marker_in_req

        extras_require={{"extra": ["barbazquux [test]; {mismatch_marker}"]}},

        [options.extras_require]
        extra =
            barbazquux [test]; {mismatch_marker}

        [extra]

        [extra:{mismatch_marker_alternate}]
        barbazquux[test]
        z
        extras_require_with_marker

        extras_require={{":{mismatch_marker}": ["barbazquux"]}},

        @xfail
        [options.extras_require]
        :{mismatch_marker} = barbazquux

        [:{mismatch_marker}]
        barbazquux
        a(  
        extras_require_with_marker_in_req

        extras_require={{"extra": ["barbazquux; {mismatch_marker}"]}},

        [options.extras_require]
        extra =
            barbazquux; {mismatch_marker}

        [extra]

        [extra:{mismatch_marker_alternate}]
        barbazquux
        z
        extras_require_with_empty_section

        extras_require={{"empty": []}},

        [options.extras_require]
        empty =

        [empty]
        )invalid_markermismatch_markermismatch_marker_alternatec                 C  s   |  || | j||fi | tjdd}tj|d}tj|r?t|dd}	|	 }
W d    n1 s9w   Y  nd}
|
 |ksIJ t		tj|j
d dg ksZJ d S )	Nr9   rb   zrequires.txtrC   rD   r   r   barbazquux*)r   rf   r   r   r   existsrN   rO   r   globr&   )r2   rR   r-   r   r   r   r   r   requires_txtfpinstall_requiresr   r   r   test_requires9  s    
&zTestEggInfo.test_requiresc                 C  sJ   d}|  | tt | || W d   dS 1 sw   Y  dS )z
        Packages that pass unordered install_requires sequences
        should be rejected as they produce non-deterministic
        builds. See #458.
        z0install_requires={"fake-factory==0.5.2", "pytz"}N)r   rs   rt   r~   rf   )r2   rR   r-   reqr   r   r   *test_install_requires_unordered_disallowed  s
   
"z6TestEggInfo.test_install_requires_unordered_disallowedc                 C  x   d}|j | jd}| | tt | || W d    n1 s$w   Y  ttj	
|jd dg ks:J d S )Nz/extras_require={{":{marker}": ["barbazquux"]}},markerr   r   r,   r   r   rs   rt   r~   rf   r   r   r   r   r&   r2   rR   r-   tmplr   r   r   r   'test_extras_require_with_invalid_marker     
&z3TestEggInfo.test_extras_require_with_invalid_markerc                 C  r   )Nz5extras_require={{"extra": ["barbazquux; {marker}"]}},r   r   r   r   r   r   r   r   .test_extras_require_with_invalid_marker_in_req  r   z:TestEggInfo.test_extras_require_with_invalid_marker_in_reqc                 C  s   |  d tj j|jd d}tjdgtj	|jd t
|gd|d tj	dd	}ttj	|d
dd}| d}W d    n1 sJw   Y  d|v sUJ d|v s[J d S )Nz*extras_require={"foobar": ["barbazquux"]},r   HOMEr   r   r   cmdpypathdata_streamr-   r9   rb   rc   rC   rD   r   zProvides-Extra: foobarMetadata-Version: 2.4r   r   environcopyupdater&   r   run_setup_pypathsepr   strr   rN   rO   r;   r2   rR   r-   r   r   r   r4   r   r   r   test_provides_extra  s    

zTestEggInfo.test_provides_extrac                 C  s   |  d tj j|jd d}tjdgtj	|jd t
|gd|d tj	dd	}ttj	|d
dd}| }W d    n1 sGw   Y  d|vsRJ d S )Nz0install_requires=["spam ; python_version<'3.6'"]r   r   r   r   r   r   r9   rb   rc   rC   rD   zProvides-Extra:)r   r   r   r   r   r&   r   r   r   r   r   r   rN   rO   )r2   rR   r-   r   r   r   pkg_info_textr   r   r   test_doesnt_provides_extra  s"   

z&TestEggInfo.test_doesnt_provides_extra)fileslicense_in_sourcesz}
                              [metadata]
                              license_file = LICENSE
                              zTest license)rA   LICENSETz
                              [metadata]
                              license_file = INVALID_LICENSE
                              z
                              zexclude LICENSE)rA   r   r   z
                              [metadata]
                              license_file = LICEN[CS]E*
                              glob_pattern)idc                 C  s   |    t| tjdgtj|jd t	|gd tjdd}t
|djdd}|r6d	|v s4J d S d	|vs<J d
|vsBJ d S )Nr   r   r   r   r9   rb   rd   rC   rD   r   INVALID_LICENSE)r3   r   r+   r   r   r   r   r   r&   r   r   	read_text)r2   rR   r-   r   r   r   sources_textr   r   r   test_setup_cfg_license_file!  s   B
z'TestEggInfo.test_setup_cfg_license_file)r   incl_licensesexcl_licensesz
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                              ABC licenseXYZ license)rA   LICENSE-ABCLICENSE-XYZr   r   z
                              [metadata]
                              license_files = LICENSE-ABC, LICENSE-XYZ
                              z
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                              zv
                              [metadata]
                              license_files =
                              z
                              [metadata]
                              license_files = LICENSE-XYZ
                              z
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  INVALID_LICENSE
                              )rA   r   r   r   z~
                              [metadata]
                              license_files = LICENSE
                              zexclude LICENSE-XYZ)rA   r   r   r   r   zABC copyingz
ABC noticezABC authorsLicensezInvalid license)rA   r   COPYING-ABC
NOTICE-ABCAUTHORS-ABCLICENCE-XYZr   INVALID-LICENSE)r   r   r   r   r   r   r   default_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE*
                              z
XYZ notice)rA   r   
NOTICE-XYZr   no_default_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  LICENSE*
                              files_only_added_oncez
                              [metadata]
                              license_files = **/LICENSE
                              zDon't includeVendor license)rA   r   LICENSE-OTHERvendorzvendor/LICENSEr   recursive_globc           
      C     |    t| tjdgtj|jd t	|gd tjdd}t
|djdd}d	d
 | D }|D ]}	||	dksBJ q7|D ]}	||	dksPJ qEd S )Nr   r   r   r9   rb   rd   rC   rD   c                 S     g | ]}|  qS r   r   r   liner   r   r   r   Q      z<TestEggInfo.test_setup_cfg_license_files.<locals>.<listcomp>r   r   r3   r   r+   r   r   r   r   r   r&   r   r   r   
splitlinescount
r2   rR   r-   r   r   r   r   r   sources_lineslfr   r   r   test_setup_cfg_license_filesu  s    S
z(TestEggInfo.test_setup_cfg_license_filesz
                              [metadata]
                              license_file =
                              license_files =
                              z
                              [metadata]
                              license_file =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                              a  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              zPQR license)rA   r   LICENSE-PQRr   )r   r  r   a9  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-ABC
                                  LICENSE-XYZ
                                  LICENSE-PQR
                              z
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                  LICENSE-XYZ
                              r  )rA   r  a  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                LICENSE-PQR
                                LICENSE-XYZ
                              z'exclude LICENSE-ABC
exclude LICENSE-PQR)rA   r   r   r  r   z~
                              [metadata]
                              license_file = LICENSE*
                              z
                              [metadata]
                              license_file = LICENSE*
                              license_files =
                                NOTICE*
                              )rA   r   r   r   r   r   combined_glob_patterrnsc           
      C  r  )Nr   r   r   r9   rb   rd   rC   rD   c                 S  r  r   r  r  r   r   r   r   	  r  zITestEggInfo.test_setup_cfg_license_file_license_files.<locals>.<listcomp>r   r   r  r
  r   r   r   )test_setup_cfg_license_file_license_filesY  s    '
z5TestEggInfo.test_setup_cfg_license_file_license_filesc              	   C  s
  |    ttdddddddid tjd	gtj|j	d
 t
|gd tjdd}ttj|ddd}| d}W d   n1 sKw   Y  dd |D }t|dks_J d|d ksgJ d|dd v sqJ d|dd v s{J d|d v sJ dS )zCAll matched license files should have a corresponding License-File.z
                              [metadata]
                              license_files =
                                  NOTICE*
                                  LICENSE*
                                  **/LICENSE
                              r   r   includedznot includer   r   )rA   r   r   NOTICEIGNOREr   r   r   r   r9   rb   rc   rC   rD   r   Nc                 S  s   g | ]	}| d r|qS )zLicense-File:)r   r  r   r   r   r   ,  s
    
z?TestEggInfo.test_license_file_attr_pkg_info.<locals>.<listcomp>   zLicense-File: NOTICEr   zLicense-File: LICENSE-ABCr   zLicense-File: LICENSE-XYZzLicense-File: vendor/LICENSEr   )r3   r   r+   r   r   r   r   r   r   r&   r   rN   rO   r;   r   )r2   rR   r-   r   r   r4   license_file_linesr   r   r   test_license_file_attr_pkg_info  s6   	z+TestEggInfo.test_license_file_attr_pkg_infoc                 C  s   |  d tjdgtj|jd t|gdd tjdd}t	tj|dd	d
}|
 d}W d   n1 s=w   Y  | |dksKJ dS )z5Make sure latest metadata version is used by default.r   r   r   r   r   r   r   r9   rb   rc   rC   rD   r   N)r:   r  )r   r   r   r   r   r   r&   r   r   rN   rO   r;   r@   r2   rR   r-   r   r   r4   r   r   r   test_metadata_version8  s   
z!TestEggInfo.test_metadata_versionc                 C  s   |  d tj j|jd d}tjdgtj	|jd t
|gd|d tj	dd	}ttj	|d
dd}| d}W d    n1 sJw   Y  d}||v sWJ d|v s]J d S )Nz.long_description_content_type='text/markdown',r   r   r   r   r   r   r9   rb   rc   rC   rD   r   z'Description-Content-Type: text/markdownr   r   r2   rR   r-   r   r   r   r4   expected_liner   r   r   "test_long_description_content_typeF  s&   
z.TestEggInfo.test_long_description_content_typec                 C  s   |  d tjdgtj|jd t|gdd tjdd}t	tj|dd	d
}|
 d}W d    n1 s=w   Y  d|v sHJ d|d ksPJ ||dd  }d|v s_J d|v seJ d S )Nzqlong_description='This is a long description\nover multiple lines',long_description_content_type='text/markdown',r   r   r   r  r9   rb   rc   rC   rD   r   r   r   zThis is a long descriptionzover multiple lines)r   r   r   r   r   r   r&   r   r   rN   rO   r;   index)r2   rR   r-   r   r   r4   long_desc_linesr   r   r   test_long_descriptiona  s"   z!TestEggInfo.test_long_descriptionc                 C  s   |  d tj j|jd d}tjdgtj	|jd t
|gd|d tj	dd	}ttj	|d
dd}| d}W d    n1 sJw   Y  d}||v sWJ d}||v s_J | |dkshJ d S )Nzproject_urls={
                'Link One': 'https://example.com/one/',
                'Link Two': 'https://example.com/two/',
                },r   r   r   r   r   r   r9   rb   rc   rC   rD   r   z/Project-URL: Link One, https://example.com/one/z/Project-URL: Link Two, https://example.com/two/r   r:   r   r   r   r   r   r&   r   r   r   r   r   r   rN   rO   r;   r@   r  r   r   r   test_project_urlsx  s*   
zTestEggInfo.test_project_urlsc                 C  s   |  d tjdgtj|jd t|gdd tjdd}t	tj|dd	d
}|
 d}W d   n1 s=w   Y  d|v sHJ dS )zTest single line license.zlicense='MIT',r   r   r   r  r9   rb   rc   rC   rD   r   NzLicense: MITr   r   r   r   r   r   r&   r   r   rN   rO   r;   r  r   r   r   test_license  s   
zTestEggInfo.test_licensec                 C  s   |  d tjdgtj|jd t|gdd tjdd}t	tj|dd	d
}|
 d}W d   n1 s=w   Y  d|v sHJ d|v sNJ dd|v sWJ dS )z:Test license is escaped correctly if longer than one line.z<license='This is a long license text \nover multiple lines',r   r   r   r  r9   rb   rc   rC   rD   r   Nz%License: This is a long license text z        over multiple linesztext 
        over multipler$  r  r   r   r   test_license_escape  s   zTestEggInfo.test_license_escapec                 C  s   |  d tj j|jd d}tjdgtj	|jd t
|gd|d tj	dd	}ttj	|d
dd}| d}W d    n1 sJw   Y  d|v sUJ | |dks^J d S )Nzpython_requires='>=2.7.12',r   r   r   r   r   r   r9   rb   rc   rC   rD   r   zRequires-Python: >=2.7.12r!  r"  r   r   r   r   test_python_requires_egg_info  s    

z)TestEggInfo.test_python_requires_egg_infoc                 C  s$   ddg}|D ]	}t |sJ qd S )Nz:standard file not found: should have one of foo.py, bar.pyz"standard file 'setup.py' not found)r   _should_suppress_warning)r2   fixturesrz   r   r   r   'test_manifest_maker_warning_suppression  s   z3TestEggInfo.test_manifest_maker_warning_suppressionc                 C  s   |    tddd}d|_t|}|  |  d|jjv s"J t|jd dd}|	 
d	}d|v s9J W d    d S 1 sDw   Y  d S )
Nfoo0.0.1r   versionznon_setup.pyr0   z/SOURCES.txtrC   rD   r   )r3   r
   script_namer   finalize_optionsrv   filelistr   rN   rO   r;   )r2   rR   rT   egg_info_instancerV   sourcesr   r   r   test_egg_info_includes_setup_py  s   "z+TestEggInfo.test_egg_info_includes_setup_pyNc                 C  sv   t j j|jd d}|d u rdg}tj|t j|jd t	|gd|d\}}|r/J ||r7||v s9J d S d S )Nr   r   r   r   r   r   )
r   r   r   r   r&   r   r   r   r   r   )r2   rR   r-   r   outputr   coder   r   r   r   rf     s"   

z!TestEggInfo._run_egg_info_commandc                 C  s   |    tdtdi | || tjdd}ttj|ddd}| 	d}W d    n1 s7w   Y  d	|v sBJ d S )
NrA   z
                              [egg_info]
                              tag_build = dev
                              tag_date = 0
                              tag_svn_revision = 0
                              r9   rb   rc   rC   rD   r   zVersion: 0.0.0.dev0r   r  r   r   r   test_egg_info_tag_only_once  s   
z'TestEggInfo.test_egg_info_tag_only_once)r4   r5   r6   r7   )F)NN)0r   r   r   r   r1   r3   r   r@   rY   rP   ra   rj   r{   r   r   r   r   sysversion_infor   r   r   r   r   r   r   r   r   r   r   rs   r   r   r   r  r  r  r  r  r   r#  r%  r&  r'  r*  r4  rf   r7  r   r   r   r   r/   1   s   
	#!
.
  
		
	
A




  
P	
		
  
$' 	
r/   c                   @  s   e Zd Zdd Zdd ZdS )TestWriteEntriesc                 C  s   t ddd}ddi|_|d}d}tjtjtf|d"}t|dd	 d
|j	j
d v s.J dt|j	v s7J W d    d S 1 sBw   Y  d S )Nr+  r,  r-  zfoo = invalid-identifier:foor   z,(Invalid object reference|Problems to parse)rn   entry_pointsre   z#ensure entry-point follows the specr   zinvalid-identifier)r
   r;  get_command_objrs   rt   r   OptionErrorr}   r	   r   r   r   )r2   rR   r-   rT   r   expected_msgexr   r   r   test_invalid_entry_point  s   

"z)TestWriteEntries.test_invalid_entry_pointc                 C  s^   t ddd}ddgd|_|d}t|dd	 td	jd
d}d|v s'J d|v s-J d S )Nr+  r,  r-  zfoo = bar:bazzfaa = bor:boz)abcdefr   r;  re   rC   rD   z[abc]
foo = bar:baz
z[def]
faa = bor:boz
)r
   r;  r<  r	   r   r   )r2   rR   r-   rT   r   rW   r   r   r   test_valid_entry_point  s   
z'TestWriteEntries.test_valid_entry_pointN)r   r   r   r@  rC  r   r   r   r   r:    s    
r:  )#
__future__r   r   r   r   rZ   r#   r8  r   pathlibr   unittestr   rs   jaracor   
setuptoolsr   setuptools.command.egg_infor   r   r	   setuptools.distr
   r   r   r   textwrapr   r   r   fixturer-   r/   r:  r   r   r   r   <module>   s>    
         ]