Skip to content

Commit ebc218a

Browse files
committed
Add basic test for input
1 parent 46083e3 commit ebc218a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

stdlib/builtin/tests/builtin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,16 @@ class C: pass
469469
assert lib.libvar == 43
470470
assert lib.libclass().method() == 44
471471

472+
doc="input"
473+
import sys
474+
class MockStdin:
475+
def __init__(self, line):
476+
self._line = line
477+
def readline(self):
478+
return self._line
479+
old_stdin = sys.stdin
480+
sys.stdin = MockStdin("hello\n")
481+
assert input() == "hello"
482+
sys.stdin = old_stdin
483+
472484
doc="finished"

0 commit comments

Comments
 (0)