B
    È S]O  ã               @   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 yddlZW n ek
rt   dZY nX 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 kri }|d k	r&t  ¡ }t  |¡ | jf |Ž\}}t|ƒ}| ¡  x | ¡ D ]\}}	t|||	ƒ qPW | ¡  | 	¡  |d k	rŠt  |¡ |S )N)
ÚosÚgetcwdÚchdirÚcreate_distr   Zinitialize_optionsÚitemsÚsetattrZensure_finalizedÚrun)
ÚselfÚmetadataÚcwdZoptionsZold_dirÚpkg_infoÚdistÚcmdÚnameÚvalue© r   ú+lib/python3.7/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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   Z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 )Nz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dddœŽ d|d< | j|ddd}|  |jd	¡ d
|d< | j|tddd}|  |jd	¡ d S )Nztitle
===

test)r"   r!   r   )r   r   r   r   r   r"   )r    Úrestructuredtextu   title
=====

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

.. include:: includetest.rst)r   r    r-   )	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¡¡ xx|D ]p}| j|d\}}t|ƒ}| ¡  | |¡}td k	rr|  t	|ƒd¡ q*|  t	|ƒd¡ |  t
|d d ƒd¡ q*W d S )Nz}            Here's some code:

            .. code:: python

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

            .. code-block:: python

                def foo():
                    pass
            )r"   r   r!   z0Cannot analyze code. Pygments package not found.)ÚappendÚtextwrapÚdedentr   r   r.   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dddœŽ d S )Nr   )r   r   r!   )r    r-   )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   r,   r0   r6   r7   r   r   r   r   r      s   
!$r   c               C   s
   t  t¡S )N)r;   Z	makeSuiter   r   r   r   r   Ú
test_suiteŸ   s    r<   Ú__main__)Ú__doc__r   r2   r;   Ztest.supportr   Zdistutils.command.checkr   r   Zdistutils.testsr   Zdistutils.errorsr   r4   ÚImportErrorÚpathÚdirnameÚ__file__r/   ZLoggingSilencerZTempdirManagerZTestCaser   r<   r8   r   r   r   r   Ú<module>   s&   
 
