o
    LK&h!                     @   s   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 Zdd Z	G dd	 d	Z
d
d Zedddddddddddddddddddd ZdS )     N   )Metadatac                 C   s   d dd | dD S )N
c                 s   s*    | ]}|  r|  d s|V  qdS )#N)strip
startswith).0line r
   W/var/www/html/venv/lib/python3.10/site-packages/pkg_resources/tests/test_working_set.py	<genexpr>   s    
z!strip_comments.<locals>.<genexpr>)joinsplit)sr
   r
   r   strip_comments   s   
r   c                 c   s    |   } td| D ]D}|sq|dd}dt|  kr#dks&J  J |ddd\}}|rBt|d}td|f}nd}t	j
|||d	}|V  qdS )
a  
    Parse a series of distribution specs of the form:
    {project_name}-{version}
       [optional, indented requirements specification]

    Example:

        foo-0.2
        bar-1.0
          foo>=3.0
          [feature]
          baz

    yield 2 distributions:
        - project_name=foo, version=0.2
        - project_name=bar, version=1.0,
          requires=['foo>=3.0', 'baz; extra=="feature"']
    z\n(?=[^\s])r   r      r   -zrequires.txtN)project_nameversionmetadata)r   rer   lenpoprsplittextwrapdedentr   pkg_resourcesDistribution)r   specfieldsnamer   requiresr   distr
   r
   r   parse_distributions   s"    r#   c                   @   s   e Zd ZdddZdd ZdS )FakeInstallerreturnNc                 C   s
   || _ d S N)_installable_dists)selfinstallable_distsr
   r
   r   __init__;   s   
zFakeInstaller.__init__c                    s   t tt fdd| jd S )Nc                    s   |  v S r&   r
   )r"   reqr
   r   <lambda>@   s    z(FakeInstaller.__call__.<locals>.<lambda>)nextiterfilterr'   )r(   r,   r
   r+   r   __call__>   s   zFakeInstaller.__call__)r%   N)__name__
__module____qualname__r*   r1   r
   r
   r
   r   r$   :   s    
r$   c                  G   s   g }g }| D ]m}dd t | ddD \}}}}}}	tt|}tt|}tt|}|d|f|d d|	ffD ]5\}
}}||
 t	|
 }td|r`tt|}t|ts_J ntt|}|t||||| q=qtjjd	||d
S )Nc                 s   s    | ]	}t | V  qd S r&   )r   lstrip)r   r   r
   r
   r   r   O   s
    

z7parametrize_test_working_set_resolve.<locals>.<genexpr>z

   F_replace_conflictingTz\w+$)installed_distsr)   requirementsreplace_conflictingresolved_dists_or_exception)ids)r   r   r5   r   listr#   r   parse_requirementsappendr   r   r   matchgetattr
issubclass	Exceptionpytestparammarkparametrize)	test_listidlist	argvaluestestr    r8   r)   r9   	expected1	expected2id_r:   expectedr
   r
   r   $parametrize_test_working_set_resolveD   sP   

rP   z
    # id
    noop

    # installed

    # installable

    # wanted

    # resolved

    # resolved [replace conflicting]
    z
    # id
    already_installed

    # installed
    foo-3.0

    # installable

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    foo-3.0

    # resolved [replace conflicting]
    foo-3.0
    z
    # id
    installable_not_installed

    # installed

    # installable
    foo-3.0
    foo-4.0

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    foo-3.0

    # resolved [replace conflicting]
    foo-3.0
    z
    # id
    not_installable

    # installed

    # installable

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    DistributionNotFound

    # resolved [replace conflicting]
    DistributionNotFound
    z
    # id
    no_matching_version

    # installed

    # installable
    foo-3.1

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    DistributionNotFound

    # resolved [replace conflicting]
    DistributionNotFound
    z
    # id
    installable_with_installed_conflict

    # installed
    foo-3.1

    # installable
    foo-3.5

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    foo-3.5
    z
    # id
    not_installable_with_installed_conflict

    # installed
    foo-3.1

    # installable

    # wanted
    foo>=2.1,!=3.1,<4

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    DistributionNotFound
    a  
    # id
    installed_with_installed_require

    # installed
    foo-3.9
    baz-0.1
        foo>=2.1,!=3.1,<4

    # installable

    # wanted
    baz

    # resolved
    foo-3.9
    baz-0.1

    # resolved [replace conflicting]
    foo-3.9
    baz-0.1
    a  
    # id
    installed_with_conflicting_installed_require

    # installed
    foo-5
    baz-0.1
        foo>=2.1,!=3.1,<4

    # installable

    # wanted
    baz

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    DistributionNotFound
    a  
    # id
    installed_with_installable_conflicting_require

    # installed
    foo-5
    baz-0.1
        foo>=2.1,!=3.1,<4

    # installable
    foo-2.9

    # wanted
    baz

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    baz-0.1
    foo-2.9
    a  
    # id
    installed_with_installable_require

    # installed
    baz-0.1
        foo>=2.1,!=3.1,<4

    # installable
    foo-3.9

    # wanted
    baz

    # resolved
    foo-3.9
    baz-0.1

    # resolved [replace conflicting]
    foo-3.9
    baz-0.1
    a  
    # id
    installable_with_installed_require

    # installed
    foo-3.9

    # installable
    baz-0.1
        foo>=2.1,!=3.1,<4

    # wanted
    baz

    # resolved
    foo-3.9
    baz-0.1

    # resolved [replace conflicting]
    foo-3.9
    baz-0.1
    a	  
    # id
    installable_with_installable_require

    # installed

    # installable
    foo-3.9
    baz-0.1
        foo>=2.1,!=3.1,<4

    # wanted
    baz

    # resolved
    foo-3.9
    baz-0.1

    # resolved [replace conflicting]
    foo-3.9
    baz-0.1
    a  
    # id
    installable_with_conflicting_installable_require

    # installed
    foo-5

    # installable
    foo-2.9
    baz-0.1
        foo>=2.1,!=3.1,<4

    # wanted
    baz

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    baz-0.1
    foo-2.9
    z
    # id
    conflicting_installables

    # installed

    # installable
    foo-2.9
    foo-5.0

    # wanted
    foo>=2.1,!=3.1,<4
    foo>=4

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    VersionConflict
    a+  
    # id
    installables_with_conflicting_requires

    # installed

    # installable
    foo-2.9
        dep==1.0
    baz-5.0
        dep==2.0
    dep-1.0
    dep-2.0

    # wanted
    foo
    baz

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    VersionConflict
    ap  
    # id
    installables_with_conflicting_nested_requires

    # installed

    # installable
    foo-2.9
        dep1
    dep1-1.0
        subdep<1.0
    baz-5.0
        dep2
    dep2-1.0
        subdep>1.0
    subdep-0.9
    subdep-1.1

    # wanted
    foo
    baz

    # resolved
    VersionConflict

    # resolved [replace conflicting]
    VersionConflict
    z
    # id
    wanted_normalized_name_installed_canonical

    # installed
    foo.bar-3.6

    # installable

    # wanted
    foo-bar==3.6

    # resolved
    foo.bar-3.6

    # resolved [replace conflicting]
    foo.bar-3.6
    c                 C   s   t g }tt|j|  tj|j|t||d}t	
|r9t| |  W d    d S 1 s2w   Y  d S t| t|ksDJ d S )N)	installerr:   )r   
WorkingSetr=   mapadd	functoolspartialresolver$   inspectisclassrD   raisessorted)r8   r)   r9   r:   r;   wsresolve_callr
   r
   r   test_working_set_resolvew   s     
x
"r^   )rU   rX   r   r   rD   r   test_resourcesr   r   r#   r$   rP   r^   r
   r
   r
   r   <module>   sH    %
3    q