a
    åze´
  ã                   @   s   d Z ddlmZ ddlmZ ddlZddlmZ ddlZej	Z	de	j
v ZdZed ZG d	d
„ d
ejƒZG dd„ dejƒZe
dkrŒejdd dS )a6  Test warnings replacement in pyshell.py and run.py.

This file could be expanded to include traceback overrides
(in same two modules). If so, change name.
Revise if output destination changes (http://bugs.python.org/issue18318).
Make sure warnings module is left unaltered (http://bugs.python.org/issue18081).
é    )Úrun)ÚpyshellN)Úcaptured_stderrZidlezf
Warning (from warnings module):
  File "test_warning.py", line 99
    Line of code
UserWarning: Test
z>>> c                   @   s(   e Zd Ze ed¡dd„ ƒZdd„ ZdS )ÚRunWarnTestú#Does not work when run within Idle.c                 C   sD   |   tjt¡ t d¡ |   tjtj¡ t d¡ |   tjt¡ d S ©NTF)ÚassertIsÚwarningsÚshowwarningr   Úcapture_warningsÚidle_showwarning_subproc©Úself© r   ú4/usr/lib/python3.9/idlelib/idle_test/test_warning.pyÚtest_showwarnings!   s
    

zRunWarnTest.test_showwarningsc              	   C   sV   t ƒ <}t dtdd|d¡ |  t ¡ | ¡  ¡ ¡ W d   ƒ n1 sH0    Y  d S ©NZTestztest_warning.pyéc   zLine of code)r   r   r   ÚUserWarningÚassertEqualÚidlemsgÚ
splitlinesÚgetvalue©r   Úfr   r   r   Útest_run_show)   s
    ÿzRunWarnTest.test_run_showN)Ú__name__Ú
__module__Ú__qualname__ÚunittestÚskipIfÚrunning_in_idler   r   r   r   r   r   r      s   

r   c                   @   s0   e Zd Ze ed¡dd„ ƒZdd„ Zdd„ ZdS )	ÚShellWarnTestr   c                 C   sD   |   tjt¡ t d¡ |   tjtj¡ t d¡ |   tjt¡ d S r   )r   r	   r
   Úshellr   Úidle_showwarningr   r   r   r   r   3   s
    

zShellWarnTest.test_showwarningsc                 C   s"   t  dtddd¡}|  t|¡ d S r   )r#   Zidle_formatwarningr   r   r   )r   Úsr   r   r   Útest_idle_formatter;   s    
ÿz!ShellWarnTest.test_idle_formatterc              	   C   sV   t ƒ <}t dtdd|d¡ |  t ¡ | ¡  ¡ ¡ W d   ƒ n1 sH0    Y  d S r   )r   r#   r$   r   r   Úshellmsgr   r   r   r   r   r   Útest_shell_showA   s
    ÿzShellWarnTest.test_shell_showN)	r   r   r   r   r    r!   r   r&   r(   r   r   r   r   r"   1   s   

r"   Ú__main__é   )Ú	verbosity)Ú__doc__Zidlelibr   r   r#   r   Ztest.supportr   r	   r
   r   r!   r   r'   ZTestCaser   r"   Úmainr   r   r   r   Ú<module>   s   
