o
    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mZ d dl	m
Z
 d dlmZ d dlmZmZmZmZmZmZmZmZ d dlmZ d dlmZ G dd	 d	eZG d
d dZG dd deZdS )    N)DistutilsErrorDistutilsOptionError)log)
TestLoader)resource_listdirresource_existsnormalize_pathworking_setevaluate_markeradd_activation_listenerrequire
EntryPoint)Command)unique_everseenc                   @      e Zd Zdd ZdddZdS )ScanningLoaderc                 C   s   t |  t | _d S N)r   __init__set_visitedself r   S/var/www/html/olx_land/venv/lib/python3.10/site-packages/setuptools/command/test.pyr      s   
zScanningLoader.__init__Nc                 C   s   || j v rdS | j | g }|t| | t|dr$||  t|dr`t|jdD ]0}|	drF|dkrF|jd |dd  }nt
|j|d	 rV|jd | }nq/|| | q/t|d
krk| |S |d S )a  Return a suite of all tests cases contained in the given module

        If the module is a package, load tests from all the modules in it.
        If the module has an ``additional_tests`` function, call it and add
        the return value to the tests.
        Nadditional_tests__path__ z.pyz__init__.py.z/__init__.py   r   )r   addappendr   loadTestsFromModulehasattrr   r   __name__endswithr   loadTestsFromNamelen
suiteClass)r   modulepatterntestsfile	submoduler   r   r   r"      s$   



z"ScanningLoader.loadTestsFromModuler   )r$   
__module____qualname__r   r"   r   r   r   r   r      s    r   c                   @   r   )NonDataPropertyc                 C   s
   || _ d S r   fget)r   r2   r   r   r   r   B   s   
zNonDataProperty.__init__Nc                 C   s   |d u r| S |  |S r   r1   )r   objobjtyper   r   r   __get__E   s   
zNonDataProperty.__get__r   )r$   r.   r/   r   r5   r   r   r   r   r0   A   s    r0   c                   @   s   e Zd ZdZdZg dZdd Zdd Zedd	 Z	d
d Z
dd Zejg fddZeejdd Zedd Zdd Zdd Zedd Zedd ZdS )testz.Command to run unit tests after in-place buildz0run unit tests after in-place build (deprecated)))ztest-module=mz$Run 'test_suite' in specified module)ztest-suite=sz9Run single test, case or suite (e.g. 'module.test_suite'))ztest-runner=rzTest runner to usec                 C   s   d | _ d | _d | _d | _d S r   )
test_suitetest_moduletest_loadertest_runnerr   r   r   r   initialize_optionsZ   s   
ztest.initialize_optionsc                 C   s   | j r| jrd}t|| j d u r"| jd u r| jj | _ n| jd | _ | jd u r/t| jdd | _| jd u r7d| _| jd u rFt| jdd | _d S d S )Nz1You may specify a module or a suite, but not bothz.test_suiter<   z&setuptools.command.test:ScanningLoaderr=   )r:   r;   r   distributionr<   getattrr=   )r   msgr   r   r   finalize_options`   s   




ztest.finalize_optionsc                 C   s   t |  S r   )list
_test_argsr   r   r   r   	test_argss      ztest.test_argsc                 c   s:    | j stjdkrdV  | jrdV  | j r| j V  d S d S )N)      discoverz	--verbose)r:   sysversion_infoverboser   r   r   r   rD   w   s   ztest._test_argsc                 C   s4   |    |  W d   dS 1 sw   Y  dS )zI
        Backward compatibility for project_on_sys_path context.
        N)project_on_sys_path)r   funcr   r   r   with_project_on_sys_path   s   
"ztest.with_project_on_sys_pathc              
   c   sL   |  d | jddd |  d | d}tjd d  }tj }zkt|j}tj	d| t
  tdd  td|j|jf  | |g d V  W d    n!1 sXw   Y  W |tjd d < tj  tj| t
  d S W |tjd d < tj  tj| t
  d S |tjd d < tj  tj| t
  w )	Negg_info	build_extr   )inplacer   c                 S   s   |   S r   )activate)distr   r   r   <lambda>   s    z*test.project_on_sys_path.<locals>.<lambda>z%s==%s)run_commandreinitialize_commandget_finalized_commandrJ   pathmodulescopyr   egg_baseinsertr	   r   r   r   egg_nameegg_versionpaths_on_pythonpathclearupdate)r   include_distsei_cmdold_pathold_modulesproject_pathr   r   r   rM      s:   








ztest.project_on_sys_pathc              
   c   s    t  }tjd|}tjdd}z4tjt| }td||g}tj|}|r/|tjd< dV  W ||u r@tjdd dS |tjd< dS ||u rStjdd w |tjd< w )z
        Add the indicated paths to the head of the PYTHONPATH environment
        variable so that subprocesses will also see the packages at
        these paths.

        Do this in a context that restores the value on exit.
        
PYTHONPATHr   N)	objectosenvirongetpathsepjoinr   filterpop)pathsnothingorig_pythonpathcurrent_pythonpathprefixto_joinnew_pathr   r   r   r`      s"   

ztest.paths_on_pythonpathc                 C   sD   |  | j}|  | jpg }|  dd | j D }t|||S )z
        Install the requirements indicated by self.distribution and
        return an iterable of the dists that were built.
        c                 s   s2    | ]\}}| d rt|dd r|V  qdS ):r   N)
startswithr
   ).0kvr   r   r   	<genexpr>   s    
z%test.install_dists.<locals>.<genexpr>)fetch_build_eggsinstall_requirestests_requireextras_requireitems	itertoolschain)rT   ir_dtr_der_dr   r   r   install_dists   s   
ztest.install_distsc              	   C   s   |  dtj | | j}d| j}| jr|  d|  d S |  d|  tt	
d|}| |) |   |   W d    n1 sGw   Y  W d    d S W d    d S 1 s_w   Y  d S )NzWARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox. zskipping "%s" (dry run)zrunning "%s"location)announcer   WARNr   r?   rn   _argvdry_runmapoperator
attrgetterr`   rM   	run_tests)r   installed_distscmdrq   r   r   r   run   s$   

"ztest.runc                 C   sV   t jd d | j| | j| | jdd}|j s)d|j }| |t	j
 t|d S )NF)
testLoader
testRunnerexitzTest failed: %s)unittestmainr   _resolve_as_epr<   r=   resultwasSuccessfulr   r   ERRORr   )r   r6   rA   r   r   r   r      s   



ztest.run_testsc                 C   s   dg| j  S )Nr   )rE   r   r   r   r   r      rF   z
test._argvc                 C   s$   | du rdS t d|  }|  S )zu
        Load the indicated attribute value, called, as a as if it were
        specified as an entry point.
        Nzx=)r   parseresolve)valparsedr   r   r   r      s   
ztest._resolve_as_epN)r$   r.   r/   __doc__descriptionuser_optionsr>   rB   r0   rE   rD   rO   
contextlibcontextmanagerrM   staticmethodr`   r   r   r   propertyr   r   r   r   r   r   r6   K   s.    



r6   )rj   r   rJ   r   r   r   distutils.errorsr   r   	distutilsr   r   pkg_resourcesr   r   r   r	   r
   r   r   r   
setuptoolsr    setuptools.extern.more_itertoolsr   r   r0   r6   r   r   r   r   <module>   s    (
(
