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")
()
| 834 | return captured_output("stderr") |
| 835 | |
| 836 | def captured_stdin(): |
| 837 | """Capture the input to sys.stdin: |
| 838 | |
| 839 | with captured_stdin() as stdin: |
| 840 | stdin.write('hello\\n') |
| 841 | stdin.seek(0) |
| 842 | # call test code that consumes from sys.stdin |
| 843 | captured = input() |
| 844 | self.assertEqual(captured, "hello") |
| 845 | """ |
| 846 | return captured_output("stdin") |
| 847 | |
| 848 | |
| 849 | def gc_collect(): |