diff options
Diffstat (limited to 'Lib/lib2to3/tests')
-rwxr-xr-x | Lib/lib2to3/tests/test_fixers.py | 58 | ||||
-rw-r--r-- | Lib/lib2to3/tests/test_parser.py | 2 |
2 files changed, 59 insertions, 1 deletions
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py index 2e0092f..a92f14a 100755 --- a/Lib/lib2to3/tests/test_fixers.py +++ b/Lib/lib2to3/tests/test_fixers.py @@ -1215,6 +1215,14 @@ class Test_dict(FixerTestCase): a = "[i for i in d. keys( ) ]" self.check(b, a) + b = "if d. viewkeys ( ) : pass" + a = "if d. keys ( ) : pass" + self.check(b, a) + + b = "[i for i in d. viewkeys( ) ]" + a = "[i for i in d. keys( ) ]" + self.check(b, a) + def test_trailing_comment(self): b = "d.keys() # foo" a = "list(d.keys()) # foo" @@ -1234,6 +1242,16 @@ class Test_dict(FixerTestCase): ]""" self.check(b, a) + b = """[i for i in d.iterkeys() # foo + ]""" + a = """[i for i in d.keys() # foo + ]""" + self.check(b, a) + + b = "d.viewitems() # foo" + a = "d.items() # foo" + self.check(b, a) + def test_unchanged(self): for wrapper in fixer_util.consuming_calls: s = "s = %s(d.keys())" % wrapper @@ -1367,6 +1385,46 @@ class Test_dict(FixerTestCase): a = "for x in list(h.keys())[0]: print x" self.check(b, a) + def test_25(self): + b = "d.viewkeys()" + a = "d.keys()" + self.check(b, a) + + def test_26(self): + b = "d.viewitems()" + a = "d.items()" + self.check(b, a) + + def test_27(self): + b = "d.viewvalues()" + a = "d.values()" + self.check(b, a) + + def test_14(self): + b = "[i for i in d.viewkeys()]" + a = "[i for i in d.keys()]" + self.check(b, a) + + def test_15(self): + b = "(i for i in d.viewkeys())" + a = "(i for i in d.keys())" + self.check(b, a) + + def test_17(self): + b = "iter(d.viewkeys())" + a = "iter(d.keys())" + self.check(b, a) + + def test_18(self): + b = "list(d.viewkeys())" + a = "list(d.keys())" + self.check(b, a) + + def test_19(self): + b = "sorted(d.viewkeys())" + a = "sorted(d.keys())" + self.check(b, a) + class Test_xrange(FixerTestCase): fixer = "xrange" diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py index 7e649da..15b109e9 100644 --- a/Lib/lib2to3/tests/test_parser.py +++ b/Lib/lib2to3/tests/test_parser.py @@ -206,6 +206,6 @@ def diff(fn, result): finally: f.close() try: - return os.system("diff -u %s @" % fn) + return os.system("diff -u %r @" % fn) finally: os.remove("@") |