o
    JAf
                     @   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rHejdd dS 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   D   |  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   5/usr/lib/python3.10/idlelib/idle_test/test_warning.pytest_showwarnings!   
   

zRunWarnTest.test_showwarningsc              	   C   X   t  }tdtdd|d | t |   W d    d S 1 s%w   Y  d S NZTestztest_warning.pyc   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   r   r   )r	   r
   r   shellr   idle_showwarningr   r   r   r   r   3   r   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   r   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    
