Capture the output of sys.stdout: with captured_stdout() as stdout: print("hello") self.assertEqual(stdout.getvalue(), "hello\\n")
()
| 904 | setattr(sys, stream_name, orig_stdout) |
| 905 | |
| 906 | def captured_stdout(): |
| 907 | """Capture the output of sys.stdout: |
| 908 | |
| 909 | with captured_stdout() as stdout: |
| 910 | print("hello") |
| 911 | self.assertEqual(stdout.getvalue(), "hello\\n") |
| 912 | """ |
| 913 | return captured_output("stdout") |
| 914 | |
| 915 | def captured_stderr(): |
| 916 | """Capture the output of sys.stderr: |
searching dependent graphs…