11from test .support .os_helper import temp_dir
22from test .support .script_helper import assert_python_failure
3+ from test .support .warnings_helper import import_deprecated
34import unittest
45import sys
5- import cgitb
6+ cgitb = import_deprecated ( " cgitb" )
67
78class TestCgitb (unittest .TestCase ):
89
@@ -31,7 +32,7 @@ def test_html(self):
3132 def test_text (self ):
3233 try :
3334 raise ValueError ("Hello World" )
34- except ValueError as err :
35+ except ValueError :
3536 text = cgitb .text (sys .exc_info ())
3637 self .assertIn ("ValueError" , text )
3738 self .assertIn ("Hello World" , text )
@@ -41,8 +42,9 @@ def test_syshook_no_logdir_default_format(self):
4142 rc , out , err = assert_python_failure (
4243 '-c' ,
4344 ('import cgitb; cgitb.enable(logdir=%s); '
44- 'raise ValueError("Hello World")' ) % repr (tracedir ))
45- out = out .decode (sys .getfilesystemencoding ())
45+ 'raise ValueError("Hello World")' ) % repr (tracedir ),
46+ PYTHONIOENCODING = 'utf-8' )
47+ out = out .decode ()
4648 self .assertIn ("ValueError" , out )
4749 self .assertIn ("Hello World" , out )
4850 self .assertIn ("<strong><module></strong>" , out )
@@ -56,8 +58,9 @@ def test_syshook_no_logdir_text_format(self):
5658 rc , out , err = assert_python_failure (
5759 '-c' ,
5860 ('import cgitb; cgitb.enable(format="text", logdir=%s); '
59- 'raise ValueError("Hello World")' ) % repr (tracedir ))
60- out = out .decode (sys .getfilesystemencoding ())
61+ 'raise ValueError("Hello World")' ) % repr (tracedir ),
62+ PYTHONIOENCODING = 'utf-8' )
63+ out = out .decode ()
6164 self .assertIn ("ValueError" , out )
6265 self .assertIn ("Hello World" , out )
6366 self .assertNotIn ('<p>' , out )
0 commit comments