{"action":"closed","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/1447","repository_url":"https://api.github.com/repos/pytest-dev/pytest","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1447/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1447/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1447/events","html_url":"https://github.com/pytest-dev/pytest/issues/1447","id":139746247,"number":1447,"title":"AttributeError: 'OutputWriter' object has no attribute 'isatty'","user":{"login":"ldiary","id":641574,"avatar_url":"https://avatars.githubusercontent.com/u/641574?v=3","gravatar_id":"","url":"https://api.github.com/users/ldiary","html_url":"https://github.com/ldiary","followers_url":"https://api.github.com/users/ldiary/followers","following_url":"https://api.github.com/users/ldiary/following{/other_user}","gists_url":"https://api.github.com/users/ldiary/gists{/gist_id}","starred_url":"https://api.github.com/users/ldiary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldiary/subscriptions","organizations_url":"https://api.github.com/users/ldiary/orgs","repos_url":"https://api.github.com/users/ldiary/repos","events_url":"https://api.github.com/users/ldiary/events{/privacy}","received_events_url":"https://api.github.com/users/ldiary/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-10T00:37:24Z","updated_at":"2016-03-10T08:35:59Z","closed_at":"2016-03-10T08:35:59Z","body":"Here is my sample code where I am running pytest programmatically and I am overriding the sys.stdout.\r\n\r\n```\r\ndef multi_procesed(arguments, path, run_id, logfile):\r\n    sys.stdout = OutputWriter(run_id)\r\n    exit_status = pytest.main(args=arguments)\r\n```\r\n\r\nAbove code encounters the following error in pytest==2.9.0.\r\n```\r\nINTERNALERROR> Traceback (most recent call last):\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/main.py\", line 90, in wrap_session\r\nINTERNALERROR>     config._do_configure()\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/config.py\", line 834, in _do_configure\r\nINTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py\", line 729, in call_historic\r\nINTERNALERROR>     self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py\", line 338, in _hookexec\r\nINTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py\", line 333, in <lambda>\r\nINTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py\", line 596, in execute\r\nINTERNALERROR>     res = hook_impl.function(*args)\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/terminal.py\", line 47, in pytest_configure\r\nINTERNALERROR>     reporter = TerminalReporter(config, sys.stdout)\r\nINTERNALERROR>   File \"/home/ldiary/py351env/lib/python3.5/site-packages/_pytest/terminal.py\", line 115, in __init__\r\nINTERNALERROR>     self.isatty = file.isatty()\r\nINTERNALERROR> AttributeError: 'OutputWriter' object has no attribute 'isatty'\r\n```\r\n\r\nCurrently, I am using the following workaround.\r\n```\r\nC:\\Users\\ernesto.luzon\\pytest>git diff _pytest\\terminal.py\r\ndiff --git a/_pytest/terminal.py b/_pytest/terminal.py\r\nindex 825f553..22c805e 100644\r\n--- a/_pytest/terminal.py\r\n+++ b/_pytest/terminal.py\r\n@@ -112,7 +112,10 @@ class TerminalReporter:\r\n         self.currentfspath = None\r\n         self.reportchars = getreportopt(config)\r\n         self.hasmarkup = self._tw.hasmarkup\r\n-        self.isatty = file.isatty()\r\n+        try:\r\n+            self.isatty = file.isatty()\r\n+        except AttributeError:\r\n+            self.isatty = False\r\n\r\n     def hasopt(self, char):\r\n         char = {'xfailed': 'x', 'skipped': 's'}.get(char, char)\r\n```"}}