{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/1223","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1223/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1223/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1223/events","html_url":"https://github.com/pytest-dev/pytest/issues/1223","id":120400062,"number":1223,"title":"--pdb causes stderr/stdout output to be hidden","user":{"login":"foxx","id":651797,"avatar_url":"https://avatars.githubusercontent.com/u/651797?v=3","gravatar_id":"","url":"https://api.github.com/users/foxx","html_url":"https://github.com/foxx","followers_url":"https://api.github.com/users/foxx/followers","following_url":"https://api.github.com/users/foxx/following{/other_user}","gists_url":"https://api.github.com/users/foxx/gists{/gist_id}","starred_url":"https://api.github.com/users/foxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxx/subscriptions","organizations_url":"https://api.github.com/users/foxx/orgs","repos_url":"https://api.github.com/users/foxx/repos","events_url":"https://api.github.com/users/foxx/events{/privacy}","received_events_url":"https://api.github.com/users/foxx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pytest-dev/pytest/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/pytest-dev/pytest/labels/reporting","name":"reporting","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-12-04T13:18:53Z","updated_at":"2016-01-07T10:41:07Z","closed_at":null,"body":"For some reason, if I specify `--pdb`, the stdout/stderr capture output doesn't get printed, neither before or after the `pdb` shell.\r\n\r\nHere are the steps to reproduce.\r\n\r\n### Test file\r\n\r\n```\r\n$ cat hello.py\r\ndef test_wtf():\r\n    print(\"WTFWTFTWF\")\r\n    raise Exception()\r\n```\r\n\r\n### Without PDB\r\n\r\n```\r\n$ py.test hello.py\r\n============================= test session starts ==============================\r\nplatform linux -- Python 3.4.3, pytest-2.8.2, py-1.4.30, pluggy-0.3.1\r\nrootdir: /vagrant, inifile:\r\nplugins: cov-2.2.0, capturelog-0.7\r\ncollected 1 items\r\n\r\nhello.py F\r\n\r\n=================================== FAILURES ===================================\r\n___________________________________ test_wtf ___________________________________\r\n\r\n    def test_wtf():\r\n        print(\"WTFWTFTWF\")\r\n>       raise Exception()\r\nE       Exception\r\n\r\nhello.py:3: Exception\r\n----------------------------- Captured stdout call -----------------------------\r\nWTFWTFTWF\r\n================= 1 failed, 1 pytest-warnings in 0.02 seconds ==================\r\n```\r\n\r\n### With PDB\r\n\r\n```\r\n$ py.test hello.py  --pdb\r\n============================= test session starts ==============================\r\nplatform linux -- Python 3.4.3, pytest-2.8.2, py-1.4.30, pluggy-0.3.1\r\nrootdir: /vagrant, inifile:\r\nplugins: cov-2.2.0, capturelog-0.7\r\ncollected 1 items\r\n\r\nhello.py F\r\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n\r\n    def test_wtf():\r\n        print(\"WTFWTFTWF\")\r\n>       raise Exception()\r\nE       Exception\r\n\r\nhello.py:3: Exception\r\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n> /vagrant/hello.py(3)test_wtf()\r\n-> raise Exception()\r\n(Pdb)\r\n\r\n\r\n================= 1 failed, 1 pytest-warnings in 4.39 seconds ==================\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/comments/169625699","html_url":"https://github.com/pytest-dev/pytest/issues/1223#issuecomment-169625699","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1223","id":169625699,"user":{"login":"foxx","id":651797,"avatar_url":"https://avatars.githubusercontent.com/u/651797?v=3","gravatar_id":"","url":"https://api.github.com/users/foxx","html_url":"https://github.com/foxx","followers_url":"https://api.github.com/users/foxx/followers","following_url":"https://api.github.com/users/foxx/following{/other_user}","gists_url":"https://api.github.com/users/foxx/gists{/gist_id}","starred_url":"https://api.github.com/users/foxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foxx/subscriptions","organizations_url":"https://api.github.com/users/foxx/orgs","repos_url":"https://api.github.com/users/foxx/repos","events_url":"https://api.github.com/users/foxx/events{/privacy}","received_events_url":"https://api.github.com/users/foxx/received_events","type":"User","site_admin":false},"created_at":"2016-01-07T10:41:07Z","updated_at":"2016-01-07T10:41:07Z","body":"Just tried getting this to work locally, but can't seem to figure it out.\r\n\r\n```\r\ndef pytest_configure(config):\r\n    ....\r\n    PdbInvoke._config = config\r\n    ....\r\n\r\ndef pytest_exception_interact(self, node, call, report):\r\n    import _pytest.config\r\n    capman = node.config.pluginmanager.getplugin(\"capturemanager\")\r\n    if capman:\r\n        capman.suspendcapture(in_=True)\r\n    tw = _pytest.config.create_terminal_writer(self._config)\r\n    tw.line()\r\n    tw.sep(\">\", \"PDB exception interact (IO-capturing turned off)\")\r\n    _enter_pdb(node, call.excinfo, report)\r\n```\r\n\r\nThis is an almost exact copy of what is being done with `set_trace`, as seen here;\r\n\r\n```\r\n            capman = self._pluginmanager.getplugin(\"capturemanager\")\r\n            if capman:\r\n                capman.suspendcapture(in_=True)\r\n            tw = _pytest.config.create_terminal_writer(self._config)\r\n            tw.line()\r\n            tw.sep(\">\", \"PDB set_trace (IO-capturing turned off)\")\r\n            self._pluginmanager.hook.pytest_enter_pdb()\r\n```\r\n\r\nThere's a lot of monkeypatching and magic in here that I don't really understand, I could probably figure it out but it would take me 7396749373 times longer than others with an understanding of the internals.\r\n\r\nIf someone can give me a pointer in the right direction then I'll happily try again"}}