{"action":"opened","issue":{"url":"https://api.github.com/repos/treyhunner/patchio/issues/2","labels_url":"https://api.github.com/repos/treyhunner/patchio/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/treyhunner/patchio/issues/2/comments","events_url":"https://api.github.com/repos/treyhunner/patchio/issues/2/events","html_url":"https://github.com/treyhunner/patchio/issues/2","id":114398894,"number":2,"title":"Make context manager to patch sys.stdout/sys.stderr","user":{"login":"treyhunner","id":285352,"avatar_url":"https://avatars.githubusercontent.com/u/285352?v=3","gravatar_id":"","url":"https://api.github.com/users/treyhunner","html_url":"https://github.com/treyhunner","followers_url":"https://api.github.com/users/treyhunner/followers","following_url":"https://api.github.com/users/treyhunner/following{/other_user}","gists_url":"https://api.github.com/users/treyhunner/gists{/gist_id}","starred_url":"https://api.github.com/users/treyhunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treyhunner/subscriptions","organizations_url":"https://api.github.com/users/treyhunner/orgs","repos_url":"https://api.github.com/users/treyhunner/repos","events_url":"https://api.github.com/users/treyhunner/events{/privacy}","received_events_url":"https://api.github.com/users/treyhunner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-31T08:55:58Z","updated_at":"2015-10-31T08:55:58Z","closed_at":null,"body":"Suggested usage:\r\n\r\n```python\r\nwith patch_output() as out, err:\r\n    print_stuff()\r\n    assert out.getvalue() == \"output\"\r\n    assert err.getvalue() == \"error\"\r\n\r\nfrom io import StringIO\r\nwith patch_output(out=StringIO(), err=StringIO()) as out, err:\r\n    print_stuff()\r\n    assert out.getvalue() == \"output\"\r\n    assert err.getvalue() == \"error\"\r\n```\r\n\r\nShould `sys.stdout` and `sys.stderr` be patched separately?  It seems like you'd usually want to do both."}}