3
f
@ s d Z ddlmZ ddlmZ ddlZddlmZ ddlZej Z de j
kZdZed Z
G d d
d
ejZG dd dejZe
d
krejdd dS )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_stderrZidlezf
Warning (from warnings module):
File "test_warning.py", line 99
Line of code
UserWarning: Test
z>>> c @ s( e Zd Zejeddd Zdd ZdS )RunWarnTestz#Does not work when run within Idle.c C sD | j tjt tjd | j tjtj tjd | j tjt d S )NTF)assertIswarningsshowwarningr capture_warningsidle_showwarning_subproc)self r C/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_warning.pytest_showwarnings! s
zRunWarnTest.test_showwarningsc C sB t 2}tjdtdd|d | jtj |j j W d Q R X d S )NTestztest_warning.pyc zLine of code)r r r
UserWarningassertEqualidlemsg
splitlinesgetvalue)r fr r r
test_run_show) s zRunWarnTest.test_run_showN)__name__
__module____qualname__unittestskipIfrunning_in_idler r r r r r
r s r c @ s0 e Zd Zejeddd Zdd Zdd ZdS )
ShellWarnTestz#Does not work when run within Idle.c C sD | j tjt tjd | j tjtj tjd | j tjt d S )NTF)r r r shellr idle_showwarning)r r r r
r 3 s
zShellWarnTest.test_showwarningsc C s" t jdtddd}| jt| d S )Nr ztest_warning.pyr zLine of code)r Zidle_formatwarningr r r )r sr r r
test_idle_formatter; s z!ShellWarnTest.test_idle_formatterc C sB t 2}tjdtdd|d | jtj |j j W d Q R X d S )Nr ztest_warning.pyr zLine of code)r r r r r shellmsgr r )r r r r r
test_shell_showA s zShellWarnTest.test_shell_showN) r r r r r r r r" r$ r r r r
r 1 s r __main__ ) verbosity)__doc__Zidlelibr r r r Ztest.supportr r r r r r r# ZTestCaser r mainr r r r