summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/tests
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-12-08 03:44:10 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-12-08 03:44:10 (GMT)
commit448e81b2da41e2ad89302cc8cb384795f9f6306c (patch)
tree97798e92a82e2a2bc27085ec73eff1675a090c42 /Lib/lib2to3/tests
parente7f2186f994f84e050b869559132d28d4fe26614 (diff)
downloadcpython-448e81b2da41e2ad89302cc8cb384795f9f6306c.zip
cpython-448e81b2da41e2ad89302cc8cb384795f9f6306c.tar.gz
cpython-448e81b2da41e2ad89302cc8cb384795f9f6306c.tar.bz2
add fixer for reload() -> imp.reload() (closes #11797)\n\nPatch by Laurie Clark-Michalek and Berker Peksag
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r--Lib/lib2to3/tests/test_fixers.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index 914b3bf..d7659fa 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -282,6 +282,65 @@ class Test_apply(FixerTestCase):
b = """f(*args, **kwds)"""
self.check(a, b)
+class Test_reload(FixerTestCase):
+ fixer = "reload"
+
+ def test(self):
+ b = """reload(a)"""
+ a = """import imp\nimp.reload(a)"""
+ self.check(b, a)
+
+ def test_comment(self):
+ b = """reload( a ) # comment"""
+ a = """import imp\nimp.reload( a ) # comment"""
+ self.check(b, a)
+
+ # PEP 8 comments
+ b = """reload( a ) # comment"""
+ a = """import imp\nimp.reload( a ) # comment"""
+ self.check(b, a)
+
+ def test_space(self):
+ b = """reload( a )"""
+ a = """import imp\nimp.reload( a )"""
+ self.check(b, a)
+
+ b = """reload( a)"""
+ a = """import imp\nimp.reload( a)"""
+ self.check(b, a)
+
+ b = """reload(a )"""
+ a = """import imp\nimp.reload(a )"""
+ self.check(b, a)
+
+ def test_unchanged(self):
+ s = """reload(a=1)"""
+ self.unchanged(s)
+
+ s = """reload(f, g)"""
+ self.unchanged(s)
+
+ s = """reload(f, *h)"""
+ self.unchanged(s)
+
+ s = """reload(f, *h, **i)"""
+ self.unchanged(s)
+
+ s = """reload(f, **i)"""
+ self.unchanged(s)
+
+ s = """reload(*h, **i)"""
+ self.unchanged(s)
+
+ s = """reload(*h)"""
+ self.unchanged(s)
+
+ s = """reload(**i)"""
+ self.unchanged(s)
+
+ s = """reload()"""
+ self.unchanged(s)
+
class Test_intern(FixerTestCase):
fixer = "intern"