o
    Nix                     @   sb   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dd ZG d	d
 d
e
jZdS )    N)string_type)fixtures)basec                 c   s\    t | tr|  D ]}| }|r|ds|V  q
dS | D ]}t|D ]}|V  q%qdS )z9Yield non-empty/non-comment lines of a string or sequence#N)
isinstancer   
splitlinesstrip
startswithyield_lines)strssss r   Z/home/ubuntu/.local/lib/python3.10/site-packages/pbr/tests/functional/test_requirements.pyr
   6   s   
r
   c                 c   sv    d}g }t | D ]*}|dr.|dr)|s|r||fV  |dd  }g }q	td||| q	||fV  dS )as  Split a string or iterable thereof into (section, content) pairs

    Each ``section`` is a stripped version of the section header ("[section]")
    and each ``content`` is a list of stripped lines excluding blank lines and
    comment-only lines.  If there are any such lines before the first section
    header, they're returned in a first ``section`` of ``None``.
    N[]   zInvalid section heading)r
   r	   endswithr   
ValueErrorappend)r   sectioncontentliner   r   r   split_sectionsG   s   



r   c                   @   s   e Zd Zdd ZdS )TestRequirementParsingc                 C   s  dt dt ddi}| t|j}|d }ddgdgdd	gd
gddgd}| td}|j}| j|dd|d t	j
|d}t	j
|d}t|d}	tt|	}
W d    n1 sbw   Y  | D ]\}}dd |D }dd |
| D }| || qkd S )Ntest_reqparseaD                          bar
                        quux<1.0; python_version=='2.6'
                        requests-aws>=0.1.4    # BSD License (3 clause)
                        Routes>=1.12.3,!=2.0,!=2.1;python_version=='2.7'
                        requests-kerberos>=0.6;python_version=='2.7' # MIT
                    aP                          [metadata]
                        name = test_reqparse

                        [extras]
                        test =
                            foo
                            baz>3.2 :python_version=='2.7' # MIT
                            bar>3.3 :python_version=='2.7' # MIT # Apache
                    )zrequirements.txtz	setup.cfgbarzrequests-aws>=0.1.4zquux<1.0zRoutes!=2.0,!=2.1,>=1.12.3zrequests-kerberos>=0.6foozbaz>3.2zbar>3.3)Nz:(python_version=='2.6')z:(python_version=='2.7')testztest:(python_version=='2.7')reqParse)zsetup.pybdist_wheelF)
allow_failcwdztest_reqparse.egg-infozrequires.txtrtc                 S      g | ]
}t tj|qS r   str	packagingrequirementsRequirement.0r   r   r   r   
<listcomp>   s    zCTestRequirementParsing.test_requirement_parsing.<locals>.<listcomp>c                 S   r%   r   r&   r+   r   r   r   r-      s    )textwrapdedent
useFixturepbr_fixturesPackagespackage_dirsVenvpython_run_cmdospathjoinopendictr   itemsassertEqual)selfpkgspkg_dirspkg_direxpected_requirementsvenv
bin_pythonegg_inforequires_txtrequiresgenerated_requirementsr   expected
exp_parsed
gen_parsedr   r   r   test_requirement_parsingc   sR   	
z/TestRequirementParsing.test_requirement_parsingN)__name__
__module____qualname__rL   r   r   r   r   r   a   s    r   )r7   r.   packaging.requirementsr(   pbr._compat.fiver   	pbr.testsr   r1   pbr.tests.functionalr   r
   r   BaseTestCaser   r   r   r   r   <module>   s   (