Capture the input to sys.stdin: with captured_stdin() as stdin: stdin.write('hello\\n') stdin.seek(0) # call test code that consumes from sys.stdin captured = input() self.assertEqual(captured, "hello")
()
| 922 | return captured_output("stderr") |
| 923 | |
| 924 | def captured_stdin(): |
| 925 | """Capture the input to sys.stdin: |
| 926 | |
| 927 | with captured_stdin() as stdin: |
| 928 | stdin.write('hello\\n') |
| 929 | stdin.seek(0) |
| 930 | # call test code that consumes from sys.stdin |
| 931 | captured = input() |
| 932 | self.assertEqual(captured, "hello") |
| 933 | """ |
| 934 | return captured_output("stdin") |
| 935 | |
| 936 | |
| 937 | def gc_collect(): |
searching dependent graphs…