]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/tests/test_main.py
1 # -*- coding: utf-8 -*-
8 from lib2to3
import main
11 class TestMain(unittest
.TestCase
):
14 # Clean up logging configuration down by main.
15 del logging
.root
.handlers
[:]
17 def run_2to3_capture(self
, args
, in_capture
, out_capture
, err_capture
):
18 save_stdin
= sys
.stdin
19 save_stdout
= sys
.stdout
20 save_stderr
= sys
.stderr
21 sys
.stdin
= in_capture
22 sys
.stdout
= out_capture
23 sys
.stderr
= err_capture
25 return main
.main("lib2to3.fixes", args
)
27 sys
.stdin
= save_stdin
28 sys
.stdout
= save_stdout
29 sys
.stderr
= save_stderr
31 def test_unencodable_diff(self
):
32 input_stream
= StringIO
.StringIO(u
"print 'nothing'\nprint u'über'\n")
33 out
= StringIO
.StringIO()
34 out_enc
= codecs
.getwriter("ascii")(out
)
35 err
= StringIO
.StringIO()
36 ret
= self
.run_2to3_capture(["-"], input_stream
, out_enc
, err
)
37 self
.assertEqual(ret
, 0)
38 output
= out
.getvalue()
39 self
.assertTrue("-print 'nothing'" in output
)
40 self
.assertTrue("WARNING: couldn't encode <stdin>'s diff for "
41 "your terminal" in err
.getvalue())