MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / capture_output

Function capture_output

pythonwhat/tasks.py:49–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48@contextmanager
49def capture_output():
50 import sys
51 from io import StringIO
52
53 oldout, olderr = sys.stdout, sys.stderr
54 out = [StringIO(), StringIO()]
55 sys.stdout, sys.stderr = out
56 yield out
57 sys.stdout, sys.stderr = oldout, olderr
58 out[0] = out[0].getvalue()
59 out[1] = out[1].getvalue()
60
61
62# MC

Callers 1

get_outputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected