]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_print.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_print.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_print.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_print.py
deleted file mode 100644 (file)
index 9c8fce0..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-"""Test correct operation of the print function.\r
-"""\r
-\r
-# In 2.6, this gives us the behavior we want.  In 3.0, it has\r
-#  no function, but it still must parse correctly.\r
-from __future__ import print_function\r
-\r
-import unittest\r
-from test import test_support\r
-\r
-from StringIO import StringIO\r
-\r
-NotDefined = object()\r
-\r
-# A dispatch table all 8 combinations of providing\r
-#  sep, end, and file\r
-# I use this machinery so that I'm not just passing default\r
-#  values to print, I'm either passing or not passing in the\r
-#  arguments\r
-dispatch = {\r
-    (False, False, False):\r
-     lambda args, sep, end, file: print(*args),\r
-    (False, False, True):\r
-     lambda args, sep, end, file: print(file=file, *args),\r
-    (False, True,  False):\r
-     lambda args, sep, end, file: print(end=end, *args),\r
-    (False, True,  True):\r
-     lambda args, sep, end, file: print(end=end, file=file, *args),\r
-    (True,  False, False):\r
-     lambda args, sep, end, file: print(sep=sep, *args),\r
-    (True,  False, True):\r
-     lambda args, sep, end, file: print(sep=sep, file=file, *args),\r
-    (True,  True,  False):\r
-     lambda args, sep, end, file: print(sep=sep, end=end, *args),\r
-    (True,  True,  True):\r
-     lambda args, sep, end, file: print(sep=sep, end=end, file=file, *args),\r
-    }\r
-\r
-# Class used to test __str__ and print\r
-class ClassWith__str__:\r
-    def __init__(self, x):\r
-        self.x = x\r
-    def __str__(self):\r
-        return self.x\r
-\r
-class TestPrint(unittest.TestCase):\r
-    def check(self, expected, args,\r
-            sep=NotDefined, end=NotDefined, file=NotDefined):\r
-        # Capture sys.stdout in a StringIO.  Call print with args,\r
-        #  and with sep, end, and file, if they're defined.  Result\r
-        #  must match expected.\r
-\r
-        # Look up the actual function to call, based on if sep, end, and file\r
-        #  are defined\r
-        fn = dispatch[(sep is not NotDefined,\r
-                       end is not NotDefined,\r
-                       file is not NotDefined)]\r
-\r
-        with test_support.captured_stdout() as t:\r
-            fn(args, sep, end, file)\r
-\r
-        self.assertEqual(t.getvalue(), expected)\r
-\r
-    def test_print(self):\r
-        def x(expected, args, sep=NotDefined, end=NotDefined):\r
-            # Run the test 2 ways: not using file, and using\r
-            #  file directed to a StringIO\r
-\r
-            self.check(expected, args, sep=sep, end=end)\r
-\r
-            # When writing to a file, stdout is expected to be empty\r
-            o = StringIO()\r
-            self.check('', args, sep=sep, end=end, file=o)\r
-\r
-            # And o will contain the expected output\r
-            self.assertEqual(o.getvalue(), expected)\r
-\r
-        x('\n', ())\r
-        x('a\n', ('a',))\r
-        x('None\n', (None,))\r
-        x('1 2\n', (1, 2))\r
-        x('1   2\n', (1, ' ', 2))\r
-        x('1*2\n', (1, 2), sep='*')\r
-        x('1 s', (1, 's'), end='')\r
-        x('a\nb\n', ('a', 'b'), sep='\n')\r
-        x('1.01', (1.0, 1), sep='', end='')\r
-        x('1*a*1.3+', (1, 'a', 1.3), sep='*', end='+')\r
-        x('a\n\nb\n', ('a\n', 'b'), sep='\n')\r
-        x('\0+ +\0\n', ('\0', ' ', '\0'), sep='+')\r
-\r
-        x('a\n b\n', ('a\n', 'b'))\r
-        x('a\n b\n', ('a\n', 'b'), sep=None)\r
-        x('a\n b\n', ('a\n', 'b'), end=None)\r
-        x('a\n b\n', ('a\n', 'b'), sep=None, end=None)\r
-\r
-        x('*\n', (ClassWith__str__('*'),))\r
-        x('abc 1\n', (ClassWith__str__('abc'), 1))\r
-\r
-        # 2.x unicode tests\r
-        x(u'1 2\n', ('1', u'2'))\r
-        x(u'u\1234\n', (u'u\1234',))\r
-        x(u'  abc 1\n', (' ', ClassWith__str__(u'abc'), 1))\r
-\r
-        # errors\r
-        self.assertRaises(TypeError, print, '', sep=3)\r
-        self.assertRaises(TypeError, print, '', end=3)\r
-        self.assertRaises(AttributeError, print, '', file='')\r
-\r
-    def test_mixed_args(self):\r
-        # If an unicode arg is passed, sep and end should be unicode, too.\r
-        class Recorder(object):\r
-\r
-            def __init__(self, must_be_unicode):\r
-                self.buf = []\r
-                self.force_unicode = must_be_unicode\r
-\r
-            def write(self, what):\r
-                if self.force_unicode and not isinstance(what, unicode):\r
-                    raise AssertionError("{0!r} is not unicode".format(what))\r
-                self.buf.append(what)\r
-\r
-        buf = Recorder(True)\r
-        print(u'hi', file=buf)\r
-        self.assertEqual(u''.join(buf.buf), 'hi\n')\r
-        del buf.buf[:]\r
-        print(u'hi', u'nothing', file=buf)\r
-        self.assertEqual(u''.join(buf.buf), 'hi nothing\n')\r
-        buf = Recorder(False)\r
-        print('hi', 'bye', end=u'\n', file=buf)\r
-        self.assertIsInstance(buf.buf[1], unicode)\r
-        self.assertIsInstance(buf.buf[3], unicode)\r
-        del buf.buf[:]\r
-        print(sep=u'x', file=buf)\r
-        self.assertIsInstance(buf.buf[-1], unicode)\r
-\r
-\r
-def test_main():\r
-    test_support.run_unittest(TestPrint)\r
-\r
-if __name__ == "__main__":\r
-    test_main()\r