o
    Zh                     @  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   U/var/www/html/lang_env/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Z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                   @  s0  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gdndo Z"ejdKedpdMdNdOg dPdQgfedqdMdNdOg dPdQgfedrdMdsdNdtg dug fedvdMdsdNdtg dug fedwdMdsdNdtdPdQgdxgfedrd?dydxgdPdQgfedzd{dMdsdNd|g du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)r3   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Z	tag_buildZtag_date)r   r   r   r%   r
   r   initialize_optionssave_version_infoopenread_validate_content_order	r1   
tmpdir_cwdr,   	setup_cfgdisteifcontentZ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)rT   expectedpatternflagsr   r   r   rM   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   r@   zU
            [egg_info]
            tag_build =
            tag_date = 0
            rA   rB   rC   NrE   rF   rG   rH   )r   r   r   r%   r*   r   r
   r   rI   rJ   rK   rL   rM   rN   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)r2   _run_egg_info_commandr   listdirsorted)r1   rO   r,   actualrZ   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)Zside_effectz+setuptools.command.egg_info.egg_info.mkpath)
return_valr   z,Cannot update time stamp of directory 'None'match)r
   r   r   patchOSErrorZdistutils.errorspytestraisesr   ZDistutilsFileErrorrun)	r1   rO   r,   rQ   rR   Zutime_patchZ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()
            r/   r@   
ValueErrorr   )	r   r   r*   rm   rn   AssertionErrorrb   valueargs)r1   rO   r,   setup_configr0   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.r^   gMbP?N)r2   rb   r   r   getmtimetimesleep)r1   rO   r,   Ztimestamp_aZ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docsr8   r^   r`   rB   rC   zdocs/usage.rst

r2   r   r*   r   rb   r   r   rK   rL   r:   )r1   rO   r,   egg_info_dirZsources_txtrS   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)
             rs   )r   r   r*   )r1   requiresuse_setup_cfgr0   rx   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>FZ_in_setup_cfgTr   z@xfail
   )marksz;requires,use_setup_cfg,expected_requires,install_cmd_kwargs)Zids)lstripr:   poplenstripastliteral_evalappend
startswithrm   markZxfailparamparametrize)Z	test_listr   ZidlistZ	argvaluestestZtest_paramsZname_kwargsvalinstall_cmd_kwargsnameZsetup_py_requiresZsetup_cfg_requiresexpected_requiresZid_r   Z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 )	Nr8   r^   zrequires.txtrB   rC   r   r   barbazquux*)r   rb   r   r   r   existsrK   rL   r   globr%   )r1   rO   r,   r   r   r   r   r   Zrequires_txtfpZinstall_requiresr   r   r   test_requires4  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   rm   rn   ru   rb   )r1   rO   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   rm   rn   ru   rb   r   r   r   r   r%   r1   rO   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,   r8   r^   r_   rB   rC   r   zProvides-Extra: foobarMetadata-Version: 2.2r   r   environcopyupdater%   r   run_setup_pypathsepr   strr   rK   rL   r:   r1   rO   r,   r   r   r   r3   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   r8   r^   r_   rB   rC   zProvides-Extra:)r   r   r   r   r   r%   r   r   r   r   r   r   rK   rL   )r1   rO   r,   r   r   r   Z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)r@   LICENSETz
                              [metadata]
                              license_file = INVALID_LICENSE
                              z
                              zexclude LICENSE)r@   r   r   z
                              [metadata]
                              license_file = LICEN[CS]E*
                              Z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   r8   r^   r`   rB   rC   r   INVALID_LICENSE)r2   r   r*   r   r   r   r   r   r%   r   r   	read_text)r1   rO   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)r@   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
                              )r@   r   r   r   z~
                              [metadata]
                              license_files = LICENSE
                              zexclude LICENSE-XYZ)r@   r   r   r   r   zABC copyingz
ABC noticezABC authorsLicensezInvalid license)r@   r   COPYING-ABC
NOTICE-ABCAUTHORS-ABCLICENCE-XYZr   INVALID-LICENSE)r   r   r   r   r   r   r   Zdefault_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE*
                              z
XYZ notice)r@   r   
NOTICE-XYZr   Zno_default_glob_patternsz
                              [metadata]
                              license_files =
                                  LICENSE-ABC
                                  LICENSE*
                              Zfiles_only_added_oncec           
      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   r8   r^   r`   rB   rC   c                 S     g | ]}|  qS r   r   r   liner   r   r   r   <      z<TestEggInfo.test_setup_cfg_license_files.<locals>.<listcomp>r   r   r2   r   r*   r   r   r   r   r   r%   r   r   r   
splitlinescount
r1   rO   r,   r   r   r   r   r   Zsources_lineslfr   r   r   test_setup_cfg_license_filesp  s    C
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)r@   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   )r@   r   a  
                              [metadata]
                              license_file = LICENSE-ABC
                              license_files =
                                LICENSE-PQR
                                LICENSE-XYZ
                              z'exclude LICENSE-ABC
exclude LICENSE-PQR)r@   r   r   r   r   z~
                              [metadata]
                              license_file = LICENSE*
                              z
                              [metadata]
                              license_file = LICENSE*
                              license_files =
                                NOTICE*
                              )r@   r   r   r   r   r   Zcombined_glob_patterrnsc           
      C  r   )Nr   r   r   r8   r^   r`   rB   rC   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_filesD  s    '
z5TestEggInfo.test_setup_cfg_license_file_license_filesc                 C  s   |    ttddddd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 sHw   Y  dd |D }d|d ks\J d|dd v sfJ d|dd v spJ dS )zCAll matched license files should have a corresponding License-File.z
                              [metadata]
                              license_files =
                                  NOTICE*
                                  LICENSE*
                              r   r   Zincludedznot include)r@   r   r   ZNOTICEZIGNOREr   r   r   r8   r^   r_   rB   rC   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-XYZ)r2   r   r*   r   r   r   r   r   r   r%   r   rK   rL   r:   )r1   rO   r,   r   r   r3   Zlicense_file_linesr   r   r   test_license_file_attr_pkg_info  s0   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   r8   r^   r_   rB   rC   r   N)r9   r9   )r   r   r   r   r   r   r%   r   r   rK   rL   r:   r?   r1   rO   r,   r   r   r3   r   r   r   test_metadata_version  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   r8   r^   r_   rB   rC   r   z'Description-Content-Type: text/markdownr   r   r1   rO   r,   r   r   r   r3   Zexpected_liner   r   r   "test_long_description_content_type-  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   r8   r^   r_   rB   rC   r   r   r   zThis is a long descriptionzover multiple lines)r   r   r   r   r   r   r%   r   r   rK   rL   r:   index)r1   rO   r,   r   r   r3   Zlong_desc_linesr   r   r   test_long_descriptionH  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   r8   r^   r_   rB   rC   r   z/Project-URL: Link One, https://example.com/one/z/Project-URL: Link Two, https://example.com/two/r   r9   r   r   r   r   r   r%   r   r   r   r   r   r   rK   rL   r:   r?   r   r   r   r   test_project_urls_  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   r8   r^   r_   rB   rC   r   NzLicense: MITr   r   r   r   r   r   r%   r   r   rK   rL   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   r8   r^   r_   rB   rC   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   r8   r^   r_   rB   rC   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   Z_should_suppress_warning)r1   Zfixturesrq   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.pyr/   z/SOURCES.txtrB   rC   r   )r2   r
   script_namer   finalize_optionsro   filelistr   rK   rL   r:   )r1   rO   rQ   Zegg_info_instancerS   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   )r1   rO   r,   r   outputr   coder   r   r   r   rb     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 )
Nr@   z
                              [egg_info]
                              tag_build = dev
                              tag_date = 0
                              tag_svn_revision = 0
                              r8   r^   r_   rB   rC   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)r3   r4   r5   r6   )F)NN)0r   r   r   r   r0   r2   r   r?   rU   rM   r]   rf   rr   rz   r~   r   r   sysversion_infor   r   r   r   r   r   r   r   r   r   r   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rb   r  r   r   r   r   r.   1   s~   
	#!
)
  
		
	
A




  
@	
		
  
$# 	
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|d}t|dd	 d
|jj	d v s,J W d    d S 1 s7w   Y  d S )Nr   r   r   zfoo = invalid-identifier:foor   z(Problems to parse .*invalid-identifier.*ri   entry_pointsra   z#ensure entry-point follows the specr   )
r
   r  get_command_objrm   rn   r   OptionErrorr	   rv   rw   )r1   rO   r,   rQ   r   Z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  ra   rB   rC   z[abc]
foo = bar:baz
z[def]
faa = bor:boz
)r
   r  r  r	   r   r   )r1   rO   r,   rQ   r   rT   r   r   r   test_valid_entry_point  s   
z'TestWriteEntries.test_valid_entry_pointN)r   r   r   r  r  r   r   r   r   r    s    	r  )#
__future__r   r   r   r   rV   r"   r	  r|   pathlibr   Zunittestr   rm   Zjaracor   
setuptoolsr   Zsetuptools.command.egg_infor   r   r	   Zsetuptools.distr
   r   r   r   textwrapr   r   r   Zfixturer,   r.   r  r   r   r   r   <module>   s>    
         D