mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Merged revisions 76259,76326,76376-76377,76430,76471,76517 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ................ r76259 | georg.brandl | 2009-11-14 05:50:51 -0600 (Sat, 14 Nov 2009) | 1 line Fix terminology. ................ r76326 | georg.brandl | 2009-11-16 10:44:05 -0600 (Mon, 16 Nov 2009) | 1 line #7302: fix link. ................ r76376 | georg.brandl | 2009-11-18 13:39:14 -0600 (Wed, 18 Nov 2009) | 1 line upcase Python ................ r76377 | georg.brandl | 2009-11-18 14:05:15 -0600 (Wed, 18 Nov 2009) | 1 line Fix markup. ................ r76430 | r.david.murray | 2009-11-20 07:29:43 -0600 (Fri, 20 Nov 2009) | 2 lines Issue 7363: fix indentation in socketserver udpserver example. ................ r76471 | georg.brandl | 2009-11-23 13:53:19 -0600 (Mon, 23 Nov 2009) | 1 line #7345: fix arguments of formatyear(). ................ r76517 | benjamin.peterson | 2009-11-25 12:16:46 -0600 (Wed, 25 Nov 2009) | 29 lines Merged revisions 76160-76161,76250,76252,76447,76506 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r76160 | benjamin.peterson | 2009-11-08 18:53:48 -0600 (Sun, 08 Nov 2009) | 1 line undeprecate the -p option; it's useful for converting python3 sources ........ r76161 | benjamin.peterson | 2009-11-08 19:05:37 -0600 (Sun, 08 Nov 2009) | 1 line simplify condition ........ r76250 | benjamin.peterson | 2009-11-13 16:56:48 -0600 (Fri, 13 Nov 2009) | 1 line fix handling of a utf-8 bom #7313 ........ r76252 | benjamin.peterson | 2009-11-13 16:58:36 -0600 (Fri, 13 Nov 2009) | 1 line remove pdb turd ........ r76447 | benjamin.peterson | 2009-11-22 18:17:40 -0600 (Sun, 22 Nov 2009) | 1 line #7375 fix nested transformations in fix_urllib ........ r76506 | benjamin.peterson | 2009-11-24 18:34:31 -0600 (Tue, 24 Nov 2009) | 1 line use generator expressions in any() ........ ................
This commit is contained in:
parent
a591cde305
commit
2021100d6d
16 changed files with 83 additions and 66 deletions
|
@ -4,6 +4,7 @@ Unit tests for refactor.py.
|
|||
|
||||
import sys
|
||||
import os
|
||||
import codecs
|
||||
import operator
|
||||
import io
|
||||
import tempfile
|
||||
|
@ -45,12 +46,10 @@ class TestRefactoringTool(unittest.TestCase):
|
|||
return refactor.RefactoringTool(fixers, options, explicit)
|
||||
|
||||
def test_print_function_option(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", DeprecationWarning)
|
||||
refactor.RefactoringTool(_DEFAULT_FIXERS, {"print_function" : True})
|
||||
self.assertEqual(len(w), 1)
|
||||
msg, = w
|
||||
self.assertTrue(msg.category is DeprecationWarning)
|
||||
rt = self.rt({"print_function" : True})
|
||||
self.assertTrue(rt.grammar is pygram.python_grammar_no_print_statement)
|
||||
self.assertTrue(rt.driver.grammar is
|
||||
pygram.python_grammar_no_print_statement)
|
||||
|
||||
def test_fixer_loading_helpers(self):
|
||||
contents = ["explicit", "first", "last", "parrot", "preorder"]
|
||||
|
@ -179,10 +178,12 @@ from __future__ import print_function"""
|
|||
|
||||
try:
|
||||
rt.refactor_file(test_file, True)
|
||||
self.assertNotEqual(old_contents, read_file())
|
||||
new_contents = read_file()
|
||||
self.assertNotEqual(old_contents, new_contents)
|
||||
finally:
|
||||
with open(test_file, "wb") as fp:
|
||||
fp.write(old_contents)
|
||||
return new_contents
|
||||
|
||||
def test_refactor_file(self):
|
||||
test_file = os.path.join(FIXER_DIR, "parrot_example.py")
|
||||
|
@ -223,6 +224,11 @@ from __future__ import print_function"""
|
|||
fn = os.path.join(TEST_DATA_DIR, "different_encoding.py")
|
||||
self.check_file_refactoring(fn)
|
||||
|
||||
def test_bom(self):
|
||||
fn = os.path.join(TEST_DATA_DIR, "bom.py")
|
||||
data = self.check_file_refactoring(fn)
|
||||
self.assertTrue(data.startswith(codecs.BOM_UTF8))
|
||||
|
||||
def test_crlf_newlines(self):
|
||||
old_sep = os.linesep
|
||||
os.linesep = "\r\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue