a
    åzeO  ã                   @   s¸   d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ zddlZW n eyr   dZY n0 ej e¡ZG dd„ de
je
jejƒZd	d
„ Zedkr´eeƒ ƒ dS )z"Tests for distutils.command.check.é    N)Úrun_unittest)ÚcheckÚHAS_DOCUTILS)Úsupport)ÚDistutilsSetupErrorc                   @   sb   e Zd Zddd„Zdd„ Ze ed¡dd„ ƒZe ed¡d	d
„ ƒZ	e ed¡dd„ ƒZ
dd„ ZdS )ÚCheckTestCaseNc           
      K   sŽ   |d u ri }|d ur&t  ¡ }t  |¡ | jf i |¤Ž\}}t|ƒ}| ¡  | ¡ D ]\}}	t|||	ƒ qR| ¡  | 	¡  |d urŠt  |¡ |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Úvalue© r   ú0/usr/lib/python3.9/distutils/tests/test_check.pyÚ_run   s    

zCheckTestCase._runc                 C   s¦   |   ¡ }|  |jd¡ ddddddœ}|   |¡}|  |jd¡ | jt| j i fi ddi¤Ž | j |dd}|  |jd¡ dddddd	d
dœ}|   |¡}|  |jd¡ d S )Né   Úxxx)ÚurlÚauthorÚauthor_emailr   Úversionr   Ústricté   )r"   u   Ã‰ricu   Something about esszet ÃŸu   More things about esszet ÃŸ)r   r   r    r   r!   ÚdescriptionÚlong_description)r   ÚassertEqualÚ	_warningsÚassertRaisesr   )r   r   r   r   r   r   Útest_check_metadata)   s&    þ
ü
z!CheckTestCase.test_check_metadatazwon't test without docutilsc                 C   sT   |   ¡ \}}t|ƒ}d}| |¡}|  t|ƒd¡ d}| |¡}|  t|ƒd¡ d S )Nútitle
===

testr#   ztitle
=====

testr   )r   r   Ú_check_rst_datar&   Úlen)r   r   r   r   Úbroken_restÚmsgsÚrestr   r   r   Útest_check_documentJ   s    

z!CheckTestCase.test_check_documentc                 C   s´   d}| j |d\}}t|ƒ}| ¡  |  |jd¡ ddddd|dœ}| jt| j|fi dddœ¤Ž d|d< | j|ddd}|  |jd	¡ d
|d< | j|tddd}|  |jd	¡ d S )Nr*   ©r%   r#   r   )r   r   r    r   r!   r%   ©r"   Úrestructuredtextu   title
=====

test ÃŸr%   r   z)title
=====

.. include:: includetest.rst)r   r"   r3   )	r   r   Úcheck_restructuredtextr&   r'   r(   r   r   ÚHERE)r   r-   r   r   r   r   r   r   r   Útest_check_restructuredtextY   s&    ýÿz)CheckTestCase.test_check_restructuredtextc                 C   sž   g }|  t d¡¡ |  t d¡¡ |D ]p}| j|d\}}t|ƒ}| ¡  | |¡}td urp|  t	|ƒd¡ q(|  t	|ƒd¡ |  t
|d d ƒd¡ q(d S )Nz}            Here's some code:

            .. code:: python

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

            .. code-block:: python

                def foo():
                    pass
            r1   r   r#   z0Cannot analyze code. Pygments package not found.)ÚappendÚtextwrapÚdedentr   r   r4   r+   Úpygmentsr&   r,   Ústr)r   Zexample_rst_docsZrest_with_coder   r   r   r.   r   r   r   Ú1test_check_restructuredtext_with_syntax_highlightt   s    	
þz?CheckTestCase.test_check_restructuredtext_with_syntax_highlightc                 C   s,   dddœ}| j t| ji fi dddœ¤Ž d S )Nr   )r   r   r#   r2   )r(   r   r   )r   r   r   r   r   Útest_check_all˜   s    

ÿÿÿzCheckTestCase.test_check_all)NN)Ú__name__Ú
__module__Ú__qualname__r   r)   ÚunittestZ
skipUnlessr   r0   r6   r<   r=   r   r   r   r   r      s   
!





#r   c                   C   s
   t  t¡S r   )rA   Z	makeSuiter   r   r   r   r   Ú
test_suiteŸ   s    rB   Ú__main__)Ú__doc__r	   r8   rA   Ztest.supportr   Zdistutils.command.checkr   r   Zdistutils.testsr   Zdistutils.errorsr   r:   ÚImportErrorÚpathÚdirnameÚ__file__r5   ZLoggingSilencerZTempdirManagerZTestCaser   rB   r>   r   r   r   r   Ú<module>   s(   
þ 