B
    u9a
  ã               @   sV   d dl mZ d dlmZ d dlZd dlZd dlZG dd„ dejƒZe	dkrRe 
¡  dS )é    )Útemp_dir)Úassert_python_failureNc               @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )Ú	TestCgitbc             C   sP   d}|   t |¡d |¡¡ |   t |¡d |¡¡ |   t |¡d |¡¡ d S )NzHello Robbie!z<small>{}</small>z<strong>{}</strong>z<font color="#909090">{}</font>)ÚassertEqualÚcgitbÚsmallÚformatÚstrongÚgrey)ÚselfÚtext© r   ú /usr/lib/python3.7/test_cgitb.pyÚ
test_fonts	   s
    zTestCgitb.test_fontsc             C   s:   |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ d S )NÚ )r   r   r   r	   r
   )r   r   r   r   Útest_blanks   s    zTestCgitb.test_blanksc          
   C   s^   yt dƒ‚W nL t k
rX } z.t t ¡ ¡}|  d|¡ |  t|ƒ|¡ W d d }~X Y nX d S )NzHello WorldÚ
ValueError)r   r   ÚhtmlÚsysÚexc_infoÚassertInÚstr)r   Úerrr   r   r   r   Ú	test_html   s    zTestCgitb.test_htmlc          
   C   sZ   yt dƒ‚W nH t k
rT } z*t t ¡ ¡}|  d|¡ |  d|¡ W d d }~X Y nX d S )NzHello Worldr   )r   r   r   r   r   r   )r   r   r   r   r   r   Ú	test_text   s    zTestCgitb.test_textc          	   C   sx   t ƒ }tddt|ƒ ƒ\}}}W d Q R X | t ¡ ¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nz-czFimport cgitb; cgitb.enable(logdir=%s); raise ValueError("Hello World")r   zHello Worldz<strong>&lt;module&gt;</strong>z<p>z</p>)r   r   ÚreprÚdecoder   Úgetfilesystemencodingr   )r   ÚtracedirÚrcÚoutr   r   r   r   Ú%test_syshook_no_logdir_default_format'   s    z/TestCgitb.test_syshook_no_logdir_default_formatc          	   C   sl   t ƒ }tddt|ƒ ƒ\}}}W d Q R X | t ¡ ¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nz-czUimport cgitb; cgitb.enable(format="text", logdir=%s); raise ValueError("Hello World")r   zHello Worldz<p>z</p>)r   r   r   r   r   r   r   ZassertNotIn)r   r   r   r    r   r   r   r   Ú"test_syshook_no_logdir_text_format5   s    z,TestCgitb.test_syshook_no_logdir_text_formatN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r!   r"   r   r   r   r   r      s   
r   Ú__main__)Ztest.supportr   Ztest.support.script_helperr   Zunittestr   r   ZTestCaser   r#   Úmainr   r   r   r   Ú<module>   s   <