diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2004-02-02 13:39:01 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2004-02-02 13:39:01 (GMT) |
commit | ff83c2bacc2acd782d20b589a02420df571b89a2 (patch) | |
tree | 7bcb6273b88c7db836ac703b7d6b13ba05632be2 /Lib/test | |
parent | 96c44658b99ef2e25a977bce7f310cd2b442cd24 (diff) | |
download | cpython-ff83c2bacc2acd782d20b589a02420df571b89a2.zip cpython-ff83c2bacc2acd782d20b589a02420df571b89a2.tar.gz cpython-ff83c2bacc2acd782d20b589a02420df571b89a2.tar.bz2 |
Fix input() builtin function to respect compiler flags.
(SF patch 876178, patch by mwh, unittest by perky)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_builtin.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index db823ff..46f3d68 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -931,6 +931,19 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(input(), 'whitespace') sys.stdin = cStringIO.StringIO() self.assertRaises(EOFError, input) + + # SF 876178: make sure input() respect future options. + sys.stdin = cStringIO.StringIO('1/2') + sys.stdout = cStringIO.StringIO() + exec compile('print input()', 'test_builtin_tmp', 'exec') + sys.stdin.seek(0, 0) + exec compile('from __future__ import division;print input()', + 'test_builtin_tmp', 'exec') + sys.stdin.seek(0, 0) + exec compile('print input()', 'test_builtin_tmp', 'exec') + self.assertEqual(sys.stdout.getvalue().splitlines(), + ['0', '0.5', '0']) + del sys.stdout self.assertRaises(RuntimeError, input, 'prompt') del sys.stdin |