]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/tests/test_main.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / lib2to3 / tests / test_main.py
1 # -*- coding: utf-8 -*-
2 import sys
3 import codecs
4 import logging
5 import StringIO
6 import unittest
7
8 from lib2to3 import main
9
10
11 class TestMain(unittest.TestCase):
12
13 def tearDown(self):
14 # Clean up logging configuration down by main.
15 del logging.root.handlers[:]
16
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
24 try:
25 return main.main("lib2to3.fixes", args)
26 finally:
27 sys.stdin = save_stdin
28 sys.stdout = save_stdout
29 sys.stderr = save_stderr
30
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())