e f: @sdZddlZddlmZddlZejZdejkZddlm Z ddlm Z dZ e dZ Gd d d ejZGd d d ejZGd ddejZedkrejddddndS)a6Test 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). N)captured_stderrZidle)run)PyShellzf Warning (from warnings module): File "test_warning.py", line 99 Line of code UserWarning: Test z>>> c@s:eZdZejedddZddZdS) RunWarnTestz#Does not work when run within Idle.cCsZ|jtjttjd|jtjtjtjd|jtjtdS)NTF)assertIswarnings showwarningrcapture_warningsidle_showwarning_subproc)selfr C/opt/alt/python34/lib64/python3.4/idlelib/idle_test/test_warning.pytest_showwarnings"s   zRunWarnTest.test_showwarningscCsTtE}tjdtdd|d|jtj|jjWdQXdS)NTestztest_warning.pycz Line of code)rrr UserWarning assertEqualidlemsg splitlinesgetvalue)r fr r r test_run_show*s zRunWarnTest.test_run_showN)__name__ __module__ __qualname__unittestskipIfrunning_in_idlerrr r r r r s rc@sFeZdZejedddZddZddZdS) ShellWarnTestz#Does not work when run within Idle.cCsZ|jtjttjd|jtjtjtjd|jtjtdS)NTF)rrrshellr idle_showwarning)r r r r r3s   zShellWarnTest.test_showwarningscCs/tjdtddd}|jt|dS)Nrztest_warning.pyrz Line of code)rZidle_formatwarningrrr)r sr r r test_idle_formatter;sz!ShellWarnTest.test_idle_formattercCsTtE}tjdtdd|d|jtj|jjWdQXdS)Nrztest_warning.pyrz Line of code)rrr rrshellmsgrr)r rr r r test_shell_showAs zShellWarnTest.test_shell_showN) rrrrrrrr"r$r r r r r1s  rc@seZdZddZdS)ImportWarnTestc Cstjddp}tjdddl}|jt|d|jt|djt |j dt |dj WdQXdS) NrecordTalwaysrversionr*) rcatch_warnings simplefilterZidlelib.idleverrlenZ assertTrue issubclasscategoryDeprecationWarningZassertInstrmessage)r widlelibr r r test_idleverHs   zImportWarnTest.test_idleverN)rrrr5r r r r r%Gs r%__main__ verbosityexitF)__doc__rZ test.supportrrrrrr4rrrrr#ZTestCaserrr%mainr r r r s