o
    Ni?                     @   s   d dl mZ 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m	Z	 d dl
mZ d dlmZ dd ZG d	d
 d
ejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZdS )    )absolute_import)print_functionN)ConfigParser)setupcfg)basec                 C   sH   i }t | } t }|t|  | D ]}t||||< q|S )N)	textwrapdedentr   	read_fileioStringIOsectionsdictitems)iniconfigparsersection r   K/home/ubuntu/.local/lib/python3.10/site-packages/pbr/tests/test_setupcfg.pyconfig_from_ini   s   
r   c                   @   s   e Zd Zdd Zdd ZdS )
TestBasicsc                 C   sV  d | _ d}i dddddddd	d
ddddddddddddddgddgdddddgd d!gd"d#d$d%gd&gd'gi d(d)idgd*d+gd,gd-d.gd/d0d1gfd2d3gfgd4gd5gd6d7gd8gd6d9}t|}tjd6d:}td; t|}W d    n1 sw   Y  | || td<d= |D }d>D ]}| 	|| qd S )?Na  
            [metadata]
            name = foo
            version = 1.0
            author = John Doe
            author_email = jd@example.com
            maintainer = Jim Burke
            maintainer_email = jb@example.com
            home_page = http://example.com
            summary = A foobar project.
            description = Hello, world. This is a long description.
            download_url = http://opendev.org/x/pbr
            classifier =
                Development Status :: 5 - Production/Stable
                Programming Language :: Python
            platform =
                any
            license = Apache 2.0
            requires_dist =
                Sphinx
                requests
            setup_requires_dist =
                docutils
            python_requires = >=3.6
            provides_dist =
                bax
            provides_extras =
                bar
            obsoletes_dist =
                baz

            [files]
            packages_root = src
            packages =
                foo
            package_data =
                "" = *.txt, *.rst
                foo = *.msg
            namespace_packages =
                hello
            data_files =
                bitmaps =
                    bm/b1.gif
                    bm/b2.gif
                config =
                    cfg/data.cfg
            scripts =
                scripts/hello-world.py
            modules =
                mod1

            [backwards_compat]
            zip_safe = true
            tests_require =
              fixtures
            dependency_links =
              https://example.com/mypackage/v1.2.3.zip#egg=mypackage-1.2.3
            include_package_data = true
            namefooversionz1.0authorzJohn Doeauthor_emailzjd@example.com
maintainerz	Jim Burkemaintainer_emailzjb@example.comurlzhttp://example.comdescriptionzA foobar project.long_descriptionz)Hello, world. This is a long description.download_urlzhttp://opendev.org/x/pbrclassifiersz+Development Status :: 5 - Production/StablezProgramming Language :: Python	platformsanylicensez
Apache 2.0install_requiresSphinxrequestssetup_requiresdocutilspython_requiresz>=3.6providesbaxbarbaz srcz*.txt,z*.rstz*.msg)r0   r   hellobitmapsz	bm/b1.gifz	bm/b2.gifr   zcfg/data.cfgzscripts/hello-world.pymod1Tfixturesz<https://example.com/mypackage/v1.2.3.zip#egg=mypackage-1.2.3)provides_extras	obsoletesextras_requirepackage_dirpackagespackage_datanamespace_packages
data_filesscripts
py_moduleszip_safetests_requiredependency_linksinclude_package_data)recordalwaysc                 s   s$    | ]}t |jd d V  qdS ):r   N)strmessagesplit).0xr   r   r   	<genexpr>   s   " z)TestBasics.test_basics.<locals>.<genexpr>)z/The '[metadata] home_page' option is deprecatedz-The '[metadata] summary' option is deprecatedz0The '[metadata] classifier' option is deprecatedz.The '[metadata] platform' option is deprecatedz3The '[metadata] requires_dist' option is deprecatedz9The '[metadata] setup_requires_dist' option is deprecatedz5The '[metadata] python_requires' option is deprecatedz3The '[metadata] provides_dist' option is deprecatedz5The '[metadata] provides_extras' option is deprecatedz4The '[metadata] obsoletes_dist' option is deprecatedz+The '[files] packages' option is deprecatedz/The '[files] package_data' option is deprecatedz5The '[files] namespace_packages' option is deprecatedz-The '[files] data_files' option is deprecatedz*The '[files] scripts' option is deprecatedz*The '[files] modules' option is deprecatedz6The '[backwards_compat] zip_safe' option is deprecatedz>The '[backwards_compat] dependency_links' option is deprecatedz;The '[backwards_compat] tests_require' option is deprecatedzBThe '[backwards_compat] include_package_data' option is deprecated)
maxDiffr   warningscatch_warningssimplefilterr   setup_cfg_to_setup_kwargsassertDictEqualsetassertIn)selfconfig_textexpectedr   wactualwarning_messageswarning_messager   r   r   test_basics*   s   ;	

1
zTestBasics.test_basicsc                 C   s  d}ddi g d}t |}t|}| || tj| jd}t|d}|	d W d    n1 s5w   Y  d| }ddd	i g d
}t |}t|}| || d| }ddi g d}t |}t|}| || d| }ddd	i g d
}t |}t|}| || d S )Nz
            [metadata]
            name = foo
            description = A short package summary
            long_description = file: README.rst
        r   zA short package summary)r   r   r8   r&   z
README.rstrX   z A longer summary from the READMEz
            [metadata]
            name = foo
            description = A short package summary
            description_file = %s
        z"A longer summary from the README

)r   r   r    r8   r&   z
            [metadata]
            name = foo
            summary = A short package summary
            long_description = %s
        z
            [metadata]
            name = foo
            summary = A short package summary
            description_file = %s
        )
r   r   rQ   rR   ospathjointemp_diropenwrite)rU   rV   rW   r   rY   readmefr   r   r   test_bug_2120575   sf   






zTestBasics.test_bug_2120575N)__name__
__module____qualname__r\   re   r   r   r   r   r   (   s     r   c                   @   s`   e Zd Zddddgddgdgdgdd	fd
dddgddgdd	fddi d	fgZdd ZdS )!TestExtrasRequireParsingScenariossimple_extrasz
                [extras]
                first =
                    foo
                    bar==1.0
                second =
                    baz>=3.2
                    foo
                r   zbar==1.0zbaz>=3.2zrequests-mockordereddict)firstsecondtesttest:(python_version=='2.6'))rV   expected_extra_requireswith_markersz
                [extras]
                test =
                    foo:python_version=='2.6'
                    bar
                    baz<1.6 :python_version=='2.6'
                    zaz :python_version>'1.0'
                zbaz<1.6r.   zaz)ro   rn   	no_extraszG
            [metadata]
            long_description = foo
            c                 C   *   t | j}t|}| | j|d  d S )Nr8   )r   rV   r   rQ   assertEqualrp   rU   r   kwargsr   r   r   test_extras_parsingE  s
   


z5TestExtrasRequireParsingScenarios.test_extras_parsingN)rf   rg   rh   	scenariosrx   r   r   r   r   ri     s0    
	2ri   c                   @      e Zd Zdd ZdS )TestInvalidMarkersc                 C   s    dddii}|  ttj| d S )Nextrasrn   zfoo :bad_marker>'1.0')assertRaisesSyntaxErrorr   rQ   )rU   r   r   r   r    test_invalid_marker_raises_errorP  s   z3TestInvalidMarkers.test_invalid_marker_raises_errorN)rf   rg   rh   r   r   r   r   r   r{   N  s    r{   c                   @   s@   e Zd Zdddddddfdd	d
ddddfgZdd ZdS )TestMapFieldsParsingScenariossimple_project_urlsa  
                [metadata]
                project_urls =
                    Bug Tracker = https://bugs.launchpad.net/pbr/
                    Documentation = https://docs.openstack.org/pbr/
                    Source Code = https://opendev.org/openstack/pbr
                zhttps://bugs.launchpad.net/pbr/zhttps://docs.openstack.org/pbr/z!https://opendev.org/openstack/pbr)zBug TrackerDocumentationzSource Code)rV   expected_project_urlsquery_parametersaG  
                [metadata]
                project_urls =
                    Bug Tracker = https://bugs.launchpad.net/pbr/?query=true
                    Documentation = https://docs.openstack.org/pbr/?foo=bar
                    Source Code = https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hash
                z*https://bugs.launchpad.net/pbr/?query=truez'https://docs.openstack.org/pbr/?foo=barz@https://git.openstack.org/cgit/openstack-dev/pbr/commit/?id=hashc                 C   rt   )Nproject_urls)r   rV   r   rQ   ru   r   rv   r   r   r   test_project_url_parsing~     

z6TestMapFieldsParsingScenarios.test_project_url_parsingN)rf   rg   rh   ry   r   r   r   r   r   r   W  s&    %r   c                   @   s6   e Zd Zddg ddfdddgdfgZdd	 Zd
S )TestKeywordsParsingScenarioskeywords_listz
                [metadata]
                keywords =
                    one
                    two
                    three
                )onetwothree)rV   expected_keywordsinline_keywordszW
                [metadata]
                keywords = one, two, three
                zone, two, threec                 C   rt   )Nkeywords)r   rV   r   rQ   ru   r   rv   r   r   r   test_keywords_parsing  r   z2TestKeywordsParsingScenarios.test_keywords_parsingN)rf   rg   rh   ry   r   r   r   r   r   r     s    r   c                   @   rz   )TestProvidesExtrasc                 C   s.   d}t |}t|}| ddg|d  d S )NzX
        [metadata]
        provides_extras = foo
                          bar
        r   r.   r6   )r   r   rQ   ru   )rU   r   r   rw   r   r   r   test_provides_extras  s   
z'TestProvidesExtras.test_provides_extrasN)rf   rg   rh   r   r   r   r   r   r         r   c                   @   s.   e Zd ZdddddgfgdfgZdd Zd	S )
TestDataFilesParsingr=   z
            [files]
            data_files =
                'i like spaces/' =
                    'dir with space/file with spc 2'
                    'dir with space/file with spc 1'
            zi like spaces/zdir with space/file with spc 2zdir with space/file with spc 1)rV   r=   c                 C   rt   )Nr=   )r   rV   r   rQ   ru   r=   rv   r   r   r   )test_handling_of_whitespace_in_data_files  r   z>TestDataFilesParsing.test_handling_of_whitespace_in_data_filesN)rf   rg   rh   ry   r   r   r   r   r   r     s    	r   c                   @   rz   )TestUTF8DescriptionFilec           	      C   s|   t  \}}d}d}|| }tj|ddd}|| W d    n1 s&w   Y  t|}t|}| ||d  d S )Nz:
        [metadata]
        description_file = %s
        u    UTF8 description: é"…-ʃŋ'

rX   utf8)encodingr    )	tempfilemkstempr
   ra   rb   r   r   rQ   ru   )	rU   _r^   ini_templateunicode_descriptionr   rd   r   rw   r   r   r   test_utf8_description_file  s   
z2TestUTF8DescriptionFile.test_utf8_description_fileN)rf   rg   rh   r   r   r   r   r   r     r   r   )
__future__r   r   r
   r]   r   r   rN   pbr._compat.fiver   pbrr   	pbr.testsr   r   BaseTestCaser   ri   r{   r   r   r   r   r   r   r   r   r   <module>   s(   
 j=	.#!