]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Demo/parser/test_unparse.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Demo / parser / test_unparse.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Demo/parser/test_unparse.py b/AppPkg/Applications/Python/Python-2.7.2/Demo/parser/test_unparse.py
deleted file mode 100644 (file)
index eee1c7a..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-import unittest\r
-from test import test_support\r
-import cStringIO\r
-import sys\r
-import os\r
-import tokenize\r
-import ast\r
-import unparse\r
-\r
-def read_pyfile(filename):\r
-    """Read and return the contents of a Python source file (as a\r
-    string), taking into account the file encoding."""\r
-    with open(filename, "r") as pyfile:\r
-        source = pyfile.read()\r
-    return source\r
-\r
-for_else = """\\r
-def f():\r
-    for x in range(10):\r
-        break\r
-    else:\r
-        y = 2\r
-    z = 3\r
-"""\r
-\r
-while_else = """\\r
-def g():\r
-    while True:\r
-        break\r
-    else:\r
-        y = 2\r
-    z = 3\r
-"""\r
-\r
-relative_import = """\\r
-from . import fred\r
-from .. import barney\r
-from .australia import shrimp as prawns\r
-"""\r
-\r
-class_decorator = """\\r
-@f1(arg)\r
-@f2\r
-class Foo: pass\r
-"""\r
-\r
-elif1 = """\\r
-if cond1:\r
-    suite1\r
-elif cond2:\r
-    suite2\r
-else:\r
-    suite3\r
-"""\r
-\r
-elif2 = """\\r
-if cond1:\r
-    suite1\r
-elif cond2:\r
-    suite2\r
-"""\r
-\r
-try_except_finally = """\\r
-try:\r
-    suite1\r
-except ex1:\r
-    suite2\r
-except ex2:\r
-    suite3\r
-else:\r
-    suite4\r
-finally:\r
-    suite5\r
-"""\r
-\r
-class ASTTestCase(unittest.TestCase):\r
-    def assertASTEqual(self, ast1, ast2):\r
-        dump1 = ast.dump(ast1)\r
-        dump2 = ast.dump(ast2)\r
-        self.assertEqual(ast.dump(ast1), ast.dump(ast2))\r
-\r
-    def check_roundtrip(self, code1, filename="internal"):\r
-        ast1 = compile(code1, filename, "exec", ast.PyCF_ONLY_AST)\r
-        unparse_buffer = cStringIO.StringIO()\r
-        unparse.Unparser(ast1, unparse_buffer)\r
-        code2 = unparse_buffer.getvalue()\r
-        ast2 = compile(code2, filename, "exec", ast.PyCF_ONLY_AST)\r
-        self.assertASTEqual(ast1, ast2)\r
-\r
-class UnparseTestCase(ASTTestCase):\r
-    # Tests for specific bugs found in earlier versions of unparse\r
-\r
-    def test_del_statement(self):\r
-        self.check_roundtrip("del x, y, z")\r
-\r
-    def test_shifts(self):\r
-        self.check_roundtrip("45 << 2")\r
-        self.check_roundtrip("13 >> 7")\r
-\r
-    def test_for_else(self):\r
-        self.check_roundtrip(for_else)\r
-\r
-    def test_while_else(self):\r
-        self.check_roundtrip(while_else)\r
-\r
-    def test_unary_parens(self):\r
-        self.check_roundtrip("(-1)**7")\r
-        self.check_roundtrip("(-1.)**8")\r
-        self.check_roundtrip("(-1j)**6")\r
-        self.check_roundtrip("not True or False")\r
-        self.check_roundtrip("True or not False")\r
-\r
-    def test_integer_parens(self):\r
-        self.check_roundtrip("3 .__abs__()")\r
-\r
-    def test_huge_float(self):\r
-        self.check_roundtrip("1e1000")\r
-        self.check_roundtrip("-1e1000")\r
-        self.check_roundtrip("1e1000j")\r
-        self.check_roundtrip("-1e1000j")\r
-\r
-    def test_min_int(self):\r
-        self.check_roundtrip(str(-sys.maxint-1))\r
-        self.check_roundtrip("-(%s)" % (sys.maxint + 1))\r
-\r
-    def test_imaginary_literals(self):\r
-        self.check_roundtrip("7j")\r
-        self.check_roundtrip("-7j")\r
-        self.check_roundtrip("-(7j)")\r
-        self.check_roundtrip("0j")\r
-        self.check_roundtrip("-0j")\r
-        self.check_roundtrip("-(0j)")\r
-\r
-    def test_negative_zero(self):\r
-        self.check_roundtrip("-0")\r
-        self.check_roundtrip("-(0)")\r
-        self.check_roundtrip("-0b0")\r
-        self.check_roundtrip("-(0b0)")\r
-        self.check_roundtrip("-0o0")\r
-        self.check_roundtrip("-(0o0)")\r
-        self.check_roundtrip("-0x0")\r
-        self.check_roundtrip("-(0x0)")\r
-\r
-    def test_lambda_parentheses(self):\r
-        self.check_roundtrip("(lambda: int)()")\r
-\r
-    def test_chained_comparisons(self):\r
-        self.check_roundtrip("1 < 4 <= 5")\r
-        self.check_roundtrip("a is b is c is not d")\r
-\r
-    def test_function_arguments(self):\r
-        self.check_roundtrip("def f(): pass")\r
-        self.check_roundtrip("def f(a): pass")\r
-        self.check_roundtrip("def f(b = 2): pass")\r
-        self.check_roundtrip("def f(a, b): pass")\r
-        self.check_roundtrip("def f(a, b = 2): pass")\r
-        self.check_roundtrip("def f(a = 5, b = 2): pass")\r
-        self.check_roundtrip("def f(*args, **kwargs): pass")\r
-\r
-    def test_relative_import(self):\r
-        self.check_roundtrip(relative_import)\r
-\r
-    def test_bytes(self):\r
-        self.check_roundtrip("b'123'")\r
-\r
-    def test_set_literal(self):\r
-        self.check_roundtrip("{'a', 'b', 'c'}")\r
-\r
-    def test_set_comprehension(self):\r
-        self.check_roundtrip("{x for x in range(5)}")\r
-\r
-    def test_dict_comprehension(self):\r
-        self.check_roundtrip("{x: x*x for x in range(10)}")\r
-\r
-    def test_class_decorators(self):\r
-        self.check_roundtrip(class_decorator)\r
-\r
-    def test_elifs(self):\r
-        self.check_roundtrip(elif1)\r
-        self.check_roundtrip(elif2)\r
-\r
-    def test_try_except_finally(self):\r
-        self.check_roundtrip(try_except_finally)\r
-\r
-class DirectoryTestCase(ASTTestCase):\r
-    """Test roundtrip behaviour on all files in Lib and Lib/test."""\r
-\r
-    # test directories, relative to the root of the distribution\r
-    test_directories = 'Lib', os.path.join('Lib', 'test')\r
-\r
-    def test_files(self):\r
-        # get names of files to test\r
-        dist_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)\r
-\r
-        names = []\r
-        for d in self.test_directories:\r
-            test_dir = os.path.join(dist_dir, d)\r
-            for n in os.listdir(test_dir):\r
-                if n.endswith('.py') and not n.startswith('bad'):\r
-                    names.append(os.path.join(test_dir, n))\r
-\r
-        for filename in names:\r
-            if test_support.verbose:\r
-                print('Testing %s' % filename)\r
-            source = read_pyfile(filename)\r
-            self.check_roundtrip(source)\r
-\r
-\r
-def test_main():\r
-    test_support.run_unittest(UnparseTestCase, DirectoryTestCase)\r
-\r
-if __name__ == '__main__':\r
-    test_main()\r