mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Merged revisions 83845 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r83845 | benjamin.peterson | 2010-08-08 14:01:25 -0500 (Sun, 08 Aug 2010) | 69 lines Merged revisions 82779,82855,83740,83789-83791,83797-83801,83803,83811,83827,83844 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r82779 | benjamin.peterson | 2010-07-10 14:45:08 -0500 (Sat, 10 Jul 2010) | 1 line typo in attribute name #9217 ........ r82855 | benjamin.peterson | 2010-07-13 16:27:38 -0500 (Tue, 13 Jul 2010) | 1 line remove more extraneous commas #9245 ........ r83740 | alexandre.vassalotti | 2010-08-05 01:58:36 -0500 (Thu, 05 Aug 2010) | 4 lines Issue 5077: Update fixer for the other functions gone from the operator module. Patch by Meador Inge. ........ r83789 | benjamin.peterson | 2010-08-07 17:45:14 -0500 (Sat, 07 Aug 2010) | 1 line cleanup and use unicode consistently ........ r83790 | benjamin.peterson | 2010-08-07 17:52:06 -0500 (Sat, 07 Aug 2010) | 1 line unicode literal ........ r83791 | benjamin.peterson | 2010-08-07 17:52:55 -0500 (Sat, 07 Aug 2010) | 1 line .get() is pointless here ........ r83797 | benjamin.peterson | 2010-08-07 18:54:51 -0500 (Sat, 07 Aug 2010) | 1 line add a function to find how a node is indented ........ r83798 | benjamin.peterson | 2010-08-07 18:55:28 -0500 (Sat, 07 Aug 2010) | 1 line when splitting import statements, use correct indentation #9386 ........ r83799 | benjamin.peterson | 2010-08-07 18:57:43 -0500 (Sat, 07 Aug 2010) | 1 line double quotes ........ r83800 | benjamin.peterson | 2010-08-07 18:58:52 -0500 (Sat, 07 Aug 2010) | 1 line add another test ........ r83801 | benjamin.peterson | 2010-08-07 19:02:10 -0500 (Sat, 07 Aug 2010) | 1 line cleanup; style-nits ........ r83803 | benjamin.peterson | 2010-08-07 19:05:08 -0500 (Sat, 07 Aug 2010) | 1 line slightly more explicit ........ r83811 | benjamin.peterson | 2010-08-07 22:56:44 -0500 (Sat, 07 Aug 2010) | 4 lines Fix node.pre_order() to call the right method on its children. This was a rather tragic copy-paste error. ........ r83827 | benjamin.peterson | 2010-08-08 08:12:48 -0500 (Sun, 08 Aug 2010) | 1 line cause test to actually run and fix it ........ r83844 | benjamin.peterson | 2010-08-08 13:46:37 -0500 (Sun, 08 Aug 2010) | 1 line fix whitespace ........ ................
This commit is contained in:
parent
a0baf55b2b
commit
68c80edef8
9 changed files with 290 additions and 95 deletions
|
@ -1818,6 +1818,33 @@ class Test_urllib(FixerTestCase):
|
|||
s = "from %s import *" % old
|
||||
self.warns_unchanged(s, "Cannot handle star imports")
|
||||
|
||||
def test_indented(self):
|
||||
b = """
|
||||
def foo():
|
||||
from urllib import urlencode, urlopen
|
||||
"""
|
||||
a = """
|
||||
def foo():
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import urlopen
|
||||
"""
|
||||
self.check(b, a)
|
||||
|
||||
b = """
|
||||
def foo():
|
||||
other()
|
||||
from urllib import urlencode, urlopen
|
||||
"""
|
||||
a = """
|
||||
def foo():
|
||||
other()
|
||||
from urllib.parse import urlencode
|
||||
from urllib.request import urlopen
|
||||
"""
|
||||
self.check(b, a)
|
||||
|
||||
|
||||
|
||||
def test_import_module_usage(self):
|
||||
for old, changes in self.modules.items():
|
||||
for new, members in changes:
|
||||
|
@ -3623,6 +3650,10 @@ class Test_itertools_imports(FixerTestCase):
|
|||
a = "from itertools import bar, foo"
|
||||
self.check(b, a)
|
||||
|
||||
b = "from itertools import chain, imap, izip"
|
||||
a = "from itertools import chain"
|
||||
self.check(b, a)
|
||||
|
||||
def test_comments(self):
|
||||
b = "#foo\nfrom itertools import imap, izip"
|
||||
a = "#foo\n"
|
||||
|
@ -4303,13 +4334,89 @@ class Test_operator(FixerTestCase):
|
|||
a = "operator.contains(x, y)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator .sequenceIncludes(x, y)"
|
||||
a = "operator .contains(x, y)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator. sequenceIncludes(x, y)"
|
||||
a = "operator. contains(x, y)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_operator_isSequenceType(self):
|
||||
b = "operator.isSequenceType(x)"
|
||||
a = "import collections\nisinstance(x, collections.Sequence)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_operator_isMappingType(self):
|
||||
b = "operator.isMappingType(x)"
|
||||
a = "import collections\nisinstance(x, collections.Mapping)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_operator_isNumberType(self):
|
||||
b = "operator.isNumberType(x)"
|
||||
a = "import numbers\nisinstance(x, numbers.Number)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_operator_repeat(self):
|
||||
b = "operator.repeat(x, n)"
|
||||
a = "operator.mul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator .repeat(x, n)"
|
||||
a = "operator .mul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator. repeat(x, n)"
|
||||
a = "operator. mul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_operator_irepeat(self):
|
||||
b = "operator.irepeat(x, n)"
|
||||
a = "operator.imul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator .irepeat(x, n)"
|
||||
a = "operator .imul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
b = "operator. irepeat(x, n)"
|
||||
a = "operator. imul(x, n)"
|
||||
self.check(b, a)
|
||||
|
||||
def test_bare_isCallable(self):
|
||||
s = "isCallable(x)"
|
||||
self.warns_unchanged(s, "You should use hasattr(x, '__call__') here.")
|
||||
t = "You should use 'hasattr(x, '__call__')' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_sequenceIncludes(self):
|
||||
s = "sequenceIncludes(x, y)"
|
||||
self.warns_unchanged(s, "You should use operator.contains here.")
|
||||
t = "You should use 'operator.contains(x, y)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_operator_isSequenceType(self):
|
||||
s = "isSequenceType(z)"
|
||||
t = "You should use 'isinstance(z, collections.Sequence)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_operator_isMappingType(self):
|
||||
s = "isMappingType(x)"
|
||||
t = "You should use 'isinstance(x, collections.Mapping)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_operator_isNumberType(self):
|
||||
s = "isNumberType(y)"
|
||||
t = "You should use 'isinstance(y, numbers.Number)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_operator_repeat(self):
|
||||
s = "repeat(x, n)"
|
||||
t = "You should use 'operator.mul(x, n)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
def test_bare_operator_irepeat(self):
|
||||
s = "irepeat(y, 187)"
|
||||
t = "You should use 'operator.imul(y, 187)' here."
|
||||
self.warns_unchanged(s, t)
|
||||
|
||||
|
||||
class Test_exitfunc(FixerTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue