summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 7fdc063..c97a7f1 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -658,8 +658,6 @@ class BuiltinTest(unittest.TestCase):
id([0,1,2,3])
id({'spam': 1, 'eggs': 2, 'ham': 3})
- # Test input() later, together with raw_input
-
def test_int(self):
self.assertEqual(int(314), 314)
self.assertEqual(int(3.14), 3)
@@ -1108,7 +1106,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, oct, ())
def write_testfile(self):
- # NB the first 4 lines are also used to test input and raw_input, below
+ # NB the first 4 lines are also used to test input, below
fp = open(TESTFN, 'w')
try:
fp.write('1+1\n')
@@ -1267,7 +1265,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(OverflowError, range, -sys.maxint, sys.maxint)
self.assertRaises(OverflowError, range, 0, 2*sys.maxint)
- def test_input_and_raw_input(self):
+ def test_input(self):
self.write_testfile()
fp = open(TESTFN, 'r')
savestdin = sys.stdin
@@ -1275,29 +1273,18 @@ class BuiltinTest(unittest.TestCase):
try:
sys.stdin = fp
sys.stdout = BitBucket()
- self.assertEqual(input(), 2)
- self.assertEqual(input('testing\n'), 2)
- self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.')
- self.assertEqual(raw_input('testing\n'), 'Dear John')
+ self.assertEqual(input(), '1+1')
+ self.assertEqual(input('testing\n'), '1+1')
+ self.assertEqual(input(), 'The quick brown fox jumps over the lazy dog.')
+ self.assertEqual(input('testing\n'), 'Dear John')
sys.stdin = cStringIO.StringIO("NULL\0")
self.assertRaises(TypeError, input, 42, 42)
- sys.stdin = cStringIO.StringIO(" 'whitespace'")
- self.assertEqual(input(), 'whitespace')
+ whitespace = " 'whitespace'"
+ sys.stdin = cStringIO.StringIO(whitespace)
+ 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