A variation on support.captured_stdout() which gives a text stream having a `buffer` attribute.
(encoding='utf-8')
| 1419 | |
| 1420 | @contextlib.contextmanager |
| 1421 | def captured_stdout(encoding='utf-8'): |
| 1422 | """A variation on support.captured_stdout() which gives a text stream |
| 1423 | having a `buffer` attribute. |
| 1424 | """ |
| 1425 | orig_stdout = sys.stdout |
| 1426 | sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding) |
| 1427 | try: |
| 1428 | yield sys.stdout |
| 1429 | finally: |
| 1430 | sys.stdout = orig_stdout |
| 1431 | |
| 1432 | |
| 1433 | class CGIHandlerTestCase(unittest.TestCase): |
no outgoing calls
no test coverage detected
searching dependent graphs…