Merged revisions 77102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r77102 | benjamin.peterson | 2009-12-28 17:50:41 -0600 (Mon, 28 Dec 2009) | 50 lines
Merged revisions 76871-76872,77093-77095,77097-77101 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r76871 | benjamin.peterson | 2009-12-17 20:49:21 -0600 (Thu, 17 Dec 2009) | 1 line
handle unencodable diffs gracefully #5093
........
r76872 | benjamin.peterson | 2009-12-17 20:51:37 -0600 (Thu, 17 Dec 2009) | 1 line
fix emacs header
........
r77093 | benjamin.peterson | 2009-12-28 14:43:32 -0600 (Mon, 28 Dec 2009) | 7 lines
replace callable(x) with isinstance(x, collections.Callable) #7006
This is a more accurate translation than hasattr(x, '__call__') which failed in
the case that somebody had put __call__ in the instance dictionary.
Patch mostly by Joe Amenta.
........
r77094 | benjamin.peterson | 2009-12-28 14:45:13 -0600 (Mon, 28 Dec 2009) | 2 lines
deuglify imports
........
r77095 | benjamin.peterson | 2009-12-28 14:49:23 -0600 (Mon, 28 Dec 2009) | 1 line
remove unused flag
........
r77097 | benjamin.peterson | 2009-12-28 16:12:13 -0600 (Mon, 28 Dec 2009) | 2 lines
clean up imports and whitespace
........
r77098 | benjamin.peterson | 2009-12-28 16:43:35 -0600 (Mon, 28 Dec 2009) | 1 line
*** empty log message ***
........
r77099 | benjamin.peterson | 2009-12-28 16:45:10 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended change
........
r77100 | benjamin.peterson | 2009-12-28 16:53:21 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended changes
........
r77101 | benjamin.peterson | 2009-12-28 17:46:02 -0600 (Mon, 28 Dec 2009) | 1 line
normalize whitespace
........
................
2009-12-28 20:06:20 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
|
|
import codecs
|
2009-12-30 15:52:54 -04:00
|
|
|
import logging
|
Merged revisions 77102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r77102 | benjamin.peterson | 2009-12-28 17:50:41 -0600 (Mon, 28 Dec 2009) | 50 lines
Merged revisions 76871-76872,77093-77095,77097-77101 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r76871 | benjamin.peterson | 2009-12-17 20:49:21 -0600 (Thu, 17 Dec 2009) | 1 line
handle unencodable diffs gracefully #5093
........
r76872 | benjamin.peterson | 2009-12-17 20:51:37 -0600 (Thu, 17 Dec 2009) | 1 line
fix emacs header
........
r77093 | benjamin.peterson | 2009-12-28 14:43:32 -0600 (Mon, 28 Dec 2009) | 7 lines
replace callable(x) with isinstance(x, collections.Callable) #7006
This is a more accurate translation than hasattr(x, '__call__') which failed in
the case that somebody had put __call__ in the instance dictionary.
Patch mostly by Joe Amenta.
........
r77094 | benjamin.peterson | 2009-12-28 14:45:13 -0600 (Mon, 28 Dec 2009) | 2 lines
deuglify imports
........
r77095 | benjamin.peterson | 2009-12-28 14:49:23 -0600 (Mon, 28 Dec 2009) | 1 line
remove unused flag
........
r77097 | benjamin.peterson | 2009-12-28 16:12:13 -0600 (Mon, 28 Dec 2009) | 2 lines
clean up imports and whitespace
........
r77098 | benjamin.peterson | 2009-12-28 16:43:35 -0600 (Mon, 28 Dec 2009) | 1 line
*** empty log message ***
........
r77099 | benjamin.peterson | 2009-12-28 16:45:10 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended change
........
r77100 | benjamin.peterson | 2009-12-28 16:53:21 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended changes
........
r77101 | benjamin.peterson | 2009-12-28 17:46:02 -0600 (Mon, 28 Dec 2009) | 1 line
normalize whitespace
........
................
2009-12-28 20:06:20 -04:00
|
|
|
import io
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from lib2to3 import main
|
|
|
|
|
|
|
|
|
|
|
|
class TestMain(unittest.TestCase):
|
|
|
|
|
2009-12-30 15:52:54 -04:00
|
|
|
def tearDown(self):
|
|
|
|
# Clean up logging configuration down by main.
|
|
|
|
del logging.root.handlers[:]
|
|
|
|
|
Merged revisions 77102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r77102 | benjamin.peterson | 2009-12-28 17:50:41 -0600 (Mon, 28 Dec 2009) | 50 lines
Merged revisions 76871-76872,77093-77095,77097-77101 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r76871 | benjamin.peterson | 2009-12-17 20:49:21 -0600 (Thu, 17 Dec 2009) | 1 line
handle unencodable diffs gracefully #5093
........
r76872 | benjamin.peterson | 2009-12-17 20:51:37 -0600 (Thu, 17 Dec 2009) | 1 line
fix emacs header
........
r77093 | benjamin.peterson | 2009-12-28 14:43:32 -0600 (Mon, 28 Dec 2009) | 7 lines
replace callable(x) with isinstance(x, collections.Callable) #7006
This is a more accurate translation than hasattr(x, '__call__') which failed in
the case that somebody had put __call__ in the instance dictionary.
Patch mostly by Joe Amenta.
........
r77094 | benjamin.peterson | 2009-12-28 14:45:13 -0600 (Mon, 28 Dec 2009) | 2 lines
deuglify imports
........
r77095 | benjamin.peterson | 2009-12-28 14:49:23 -0600 (Mon, 28 Dec 2009) | 1 line
remove unused flag
........
r77097 | benjamin.peterson | 2009-12-28 16:12:13 -0600 (Mon, 28 Dec 2009) | 2 lines
clean up imports and whitespace
........
r77098 | benjamin.peterson | 2009-12-28 16:43:35 -0600 (Mon, 28 Dec 2009) | 1 line
*** empty log message ***
........
r77099 | benjamin.peterson | 2009-12-28 16:45:10 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended change
........
r77100 | benjamin.peterson | 2009-12-28 16:53:21 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended changes
........
r77101 | benjamin.peterson | 2009-12-28 17:46:02 -0600 (Mon, 28 Dec 2009) | 1 line
normalize whitespace
........
................
2009-12-28 20:06:20 -04:00
|
|
|
def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
|
|
|
|
save_stdin = sys.stdin
|
|
|
|
save_stdout = sys.stdout
|
|
|
|
save_stderr = sys.stderr
|
|
|
|
sys.stdin = in_capture
|
|
|
|
sys.stdout = out_capture
|
|
|
|
sys.stderr = err_capture
|
|
|
|
try:
|
|
|
|
return main.main("lib2to3.fixes", args)
|
|
|
|
finally:
|
|
|
|
sys.stdin = save_stdin
|
|
|
|
sys.stdout = save_stdout
|
|
|
|
sys.stderr = save_stderr
|
|
|
|
|
|
|
|
def test_unencodable_diff(self):
|
|
|
|
input_stream = io.StringIO("print 'nothing'\nprint u'über'\n")
|
2009-12-28 20:37:04 -04:00
|
|
|
out = io.BytesIO()
|
Merged revisions 77102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r77102 | benjamin.peterson | 2009-12-28 17:50:41 -0600 (Mon, 28 Dec 2009) | 50 lines
Merged revisions 76871-76872,77093-77095,77097-77101 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r76871 | benjamin.peterson | 2009-12-17 20:49:21 -0600 (Thu, 17 Dec 2009) | 1 line
handle unencodable diffs gracefully #5093
........
r76872 | benjamin.peterson | 2009-12-17 20:51:37 -0600 (Thu, 17 Dec 2009) | 1 line
fix emacs header
........
r77093 | benjamin.peterson | 2009-12-28 14:43:32 -0600 (Mon, 28 Dec 2009) | 7 lines
replace callable(x) with isinstance(x, collections.Callable) #7006
This is a more accurate translation than hasattr(x, '__call__') which failed in
the case that somebody had put __call__ in the instance dictionary.
Patch mostly by Joe Amenta.
........
r77094 | benjamin.peterson | 2009-12-28 14:45:13 -0600 (Mon, 28 Dec 2009) | 2 lines
deuglify imports
........
r77095 | benjamin.peterson | 2009-12-28 14:49:23 -0600 (Mon, 28 Dec 2009) | 1 line
remove unused flag
........
r77097 | benjamin.peterson | 2009-12-28 16:12:13 -0600 (Mon, 28 Dec 2009) | 2 lines
clean up imports and whitespace
........
r77098 | benjamin.peterson | 2009-12-28 16:43:35 -0600 (Mon, 28 Dec 2009) | 1 line
*** empty log message ***
........
r77099 | benjamin.peterson | 2009-12-28 16:45:10 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended change
........
r77100 | benjamin.peterson | 2009-12-28 16:53:21 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended changes
........
r77101 | benjamin.peterson | 2009-12-28 17:46:02 -0600 (Mon, 28 Dec 2009) | 1 line
normalize whitespace
........
................
2009-12-28 20:06:20 -04:00
|
|
|
out_enc = codecs.getwriter("ascii")(out)
|
|
|
|
err = io.StringIO()
|
|
|
|
ret = self.run_2to3_capture(["-"], input_stream, out_enc, err)
|
|
|
|
self.assertEqual(ret, 0)
|
2009-12-28 20:37:04 -04:00
|
|
|
output = out.getvalue().decode("ascii")
|
Merged revisions 77102 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r77102 | benjamin.peterson | 2009-12-28 17:50:41 -0600 (Mon, 28 Dec 2009) | 50 lines
Merged revisions 76871-76872,77093-77095,77097-77101 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r76871 | benjamin.peterson | 2009-12-17 20:49:21 -0600 (Thu, 17 Dec 2009) | 1 line
handle unencodable diffs gracefully #5093
........
r76872 | benjamin.peterson | 2009-12-17 20:51:37 -0600 (Thu, 17 Dec 2009) | 1 line
fix emacs header
........
r77093 | benjamin.peterson | 2009-12-28 14:43:32 -0600 (Mon, 28 Dec 2009) | 7 lines
replace callable(x) with isinstance(x, collections.Callable) #7006
This is a more accurate translation than hasattr(x, '__call__') which failed in
the case that somebody had put __call__ in the instance dictionary.
Patch mostly by Joe Amenta.
........
r77094 | benjamin.peterson | 2009-12-28 14:45:13 -0600 (Mon, 28 Dec 2009) | 2 lines
deuglify imports
........
r77095 | benjamin.peterson | 2009-12-28 14:49:23 -0600 (Mon, 28 Dec 2009) | 1 line
remove unused flag
........
r77097 | benjamin.peterson | 2009-12-28 16:12:13 -0600 (Mon, 28 Dec 2009) | 2 lines
clean up imports and whitespace
........
r77098 | benjamin.peterson | 2009-12-28 16:43:35 -0600 (Mon, 28 Dec 2009) | 1 line
*** empty log message ***
........
r77099 | benjamin.peterson | 2009-12-28 16:45:10 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended change
........
r77100 | benjamin.peterson | 2009-12-28 16:53:21 -0600 (Mon, 28 Dec 2009) | 1 line
revert unintended changes
........
r77101 | benjamin.peterson | 2009-12-28 17:46:02 -0600 (Mon, 28 Dec 2009) | 1 line
normalize whitespace
........
................
2009-12-28 20:06:20 -04:00
|
|
|
self.assertTrue("-print 'nothing'" in output)
|
|
|
|
self.assertTrue("WARNING: couldn't encode <stdin>'s diff for "
|
|
|
|
"your terminal" in err.getvalue())
|