]> granicus.if.org Git - python/commitdiff
Another test for __future__ print_function.
authorEric Smith <eric@trueblade.com>
Wed, 19 Mar 2008 03:13:34 +0000 (03:13 +0000)
committerEric Smith <eric@trueblade.com>
Wed, 19 Mar 2008 03:13:34 +0000 (03:13 +0000)
Lib/test/test_compiler.py

index 7d5ec7c5b81e2d0154f435cbf1ea4aee3204985d..d491b7809614340d32092723e0801f2fed9d8d04 100644 (file)
@@ -3,6 +3,7 @@ from compiler.ast import flatten
 import os, sys, time, unittest
 import test.test_support
 from random import random
+from StringIO import StringIO
 
 # How much time in seconds can pass before we print a 'Still working' message.
 _PRINT_WORKING_MSG_INTERVAL = 5 * 60
@@ -156,6 +157,16 @@ class CompilerTest(unittest.TestCase):
         self.assertEquals(dct.get('result'), 1)
 
 
+    def testPrintFunction(self):
+        c = compiler.compile('from __future__ import print_function\n'
+                             'print("a", "b", sep="**", end="++", '
+                                    'file=output)',
+                             '<string>',
+                             'exec' )
+        dct = {'output': StringIO()}
+        exec c in dct
+        self.assertEquals(dct['output'].getvalue(), 'a**b++')
+
     def _testErrEnc(self, src, text, offset):
         try:
             compile(src, "", "exec")