o
    ZhR                     @   s   d 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l	Z	zddl
Z
W n ey1   dZ
Y nw ejeZejG dd dejZdS )z"Tests for distutils.command.check.    N)check)DistutilsSetupError)supportc                   @   sF   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dS )	TestCheckNc           
      K   s   |d u ri }|d urt  }t | | jdi |\}}t|}|  | D ]
\}}	t|||	 q)|  |	  |d urEt | |S )N )
osgetcwdchdircreate_distr   Zinitialize_optionsitemssetattrZensure_finalizedrun)
selfmetadatacwdoptionsZold_dirpkg_infodistcmdnamevaluer   r   ]/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/_distutils/tests/test_check.py_run   s   

zTestCheck._runc                 C   s   |   }|jdksJ dddddd}|  |}|jdksJ tt | j i fi ddi W d    n1 s:w   Y  | j |dd}|jdksMJ dddddd	d
d}|  |}|jdkscJ d S )N   xxx)urlauthorauthor_emailr   versionr   strictT)r   u   Éricu   Something about esszet ßu   More things about esszet ß)r   r   r   r   r   descriptionlong_description)r   	_warningspytestraisesr   )r   r   r   r   r   r   test_check_metadata'   s2   

	zTestCheck.test_check_metadatac              	   C   s   dD ]A}dd|d dddddi}|  |}|jdksJ d	||d < |  |}|jdks.J d
||< ||d = |  |}|jdksCJ qd S )N)r   Z
maintainerr   r   Z_emailzName <name@email.com>r   r   r   zname@email.comName)r   r"   )r   kindr   r   r   r   r   test_check_author_maintainerQ   s    



z&TestCheck.test_check_author_maintainerc                 C   s^   t d |  \}}t|}d}||}t|dksJ d}||}t|dks-J d S )Ndocutilstitle
===

testr   ztitle
=====

testr   )r#   importorskipr
   r   _check_rst_datalen)r   r   r   r   broken_restmsgsrestr   r   r   test_check_documenti   s   


zTestCheck.test_check_documentc                 C   s   t d d}| j|d\}}t|}|  |jdksJ ddddd|d}t t | j|fi ddd W d    n1 sCw   Y  d|d	< | j|d
d
d}|jdks[J d|d	< | j|t	d
d
d}|jdksoJ d S )Nr)   r*   r!   r   r   )r   r   r   r   r   r!   r   restructuredtextu   title
=====

test ßr!   Tr   z)title
=====

.. include:: includetest.rst)r   r   r4   )
r#   r+   r
   r   check_restructuredtextr"   r$   r   r   HERE)r   r.   r   r   r   r   r   r   r   test_check_restructuredtextx   s,   
z%TestCheck.test_check_restructuredtextc                 C   s   t d tdtdg}|D ]8}| j|d\}}t|}|  ||}td ur5t	|dks4J qt	|dks=J t
|d d dksIJ qd S )Nr)   z}            Here's some code:

            .. code:: python

                def foo():
                    pass
            z            Here's some code:

            .. code-block:: python

                def foo():
                    pass
            r2   r   r   z0Cannot analyze code. Pygments package not found.)r#   r+   textwrapdedentr
   r   r5   r,   pygmentsr-   str)r   Zexample_rst_docsZrest_with_coder   r   r   r/   r   r   r   1test_check_restructuredtext_with_syntax_highlight   s(   



z;TestCheck.test_check_restructuredtext_with_syntax_highlightc                 C   sH   t t | ji fi ddd W d    d S 1 sw   Y  d S )Nr   r3   )r#   r$   r   r   )r   r   r   r   test_check_all   s   "zTestCheck.test_check_all)NN)
__name__
__module____qualname__r   r%   r(   r1   r7   r<   r=   r   r   r   r   r      s    
*)r   )__doc__r   r8   Zdistutils.command.checkr   Zdistutils.errorsr   Zdistutils.testsr   r#   r:   ImportErrorpathdirname__file__r6   Zcombine_markersZTempdirManagerr   r   r   r   r   <module>   s    