{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/1235","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1235/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1235/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1235/events","html_url":"https://github.com/pytest-dev/pytest/issues/1235","id":120890655,"number":1235,"title":"pytest explodes if getcwd fails","user":{"login":"bukzor","id":640328,"avatar_url":"https://avatars.githubusercontent.com/u/640328?v=3","gravatar_id":"","url":"https://api.github.com/users/bukzor","html_url":"https://github.com/bukzor","followers_url":"https://api.github.com/users/bukzor/followers","following_url":"https://api.github.com/users/bukzor/following{/other_user}","gists_url":"https://api.github.com/users/bukzor/gists{/gist_id}","starred_url":"https://api.github.com/users/bukzor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bukzor/subscriptions","organizations_url":"https://api.github.com/users/bukzor/orgs","repos_url":"https://api.github.com/users/bukzor/repos","events_url":"https://api.github.com/users/bukzor/events{/privacy}","received_events_url":"https://api.github.com/users/bukzor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-07T23:06:10Z","updated_at":"2015-12-09T19:01:11Z","closed_at":null,"body":"Demonstration below.\r\n\r\nWhile in my toy example it's quite clear what the issue is, the fact that it doesn't show the original error, or even have the erroneous code anywhere on the stack means that it's extremely hard to find the source of this issue in a real project.\r\n\r\n```\r\n$ cat test.py\r\ndef test_foo(tmpdir):\r\n    tmpdir.chdir()\r\n    tmpdir.remove()\r\n\r\n    assert False, 'naw'\r\n\r\n$ py.test test.py\r\n=========================================================================================== test session starts ===========================================================================================\r\nplatform linux2 -- Python 2.7.6, pytest-2.8.4, py-1.4.30, pluggy-0.3.1 -- /nail/home/buck/trees/yelp/pip-faster/venv-venv_update/bin/python2.7\r\ncachedir: ../.cache\r\nrootdir: /nail/home/buck/trees/yelp/pip-faster, inifile: pytest.ini\r\nplugins: xdist-1.13.1, timeout-1.0.0\r\ncollected 1 items\r\n\r\ntest.py::test_foo\r\nINTERNALERROR> Traceback (most recent call last):\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/main.py\", line 90, in wrap_session\r\nINTERNALERROR>     session.exitstatus = doit(config, session) or 0\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/main.py\", line 121, in _main\r\nINTERNALERROR>     config.hook.pytest_runtestloop(session=session)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 724, in __call__\r\nINTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 338, in _hookexec\r\nINTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 333, in <lambda>\r\nINTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 596, in execute\r\nINTERNALERROR>     res = hook_impl.function(*args)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/main.py\", line 146, in pytest_runtestloop\r\nINTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 724, in __call__\r\nINTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 338, in _hookexec\r\nINTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 333, in <lambda>\r\nINTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 595, in execute\r\nINTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 253, in _wrapped_call\r\nINTERNALERROR>     return call_outcome.get_result()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 279, in get_result\r\nINTERNALERROR>     _reraise(*ex)  # noqa\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 264, in __init__\r\nINTERNALERROR>     self.result = func()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 595, in execute\r\nINTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 253, in _wrapped_call\r\nINTERNALERROR>     return call_outcome.get_result()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 279, in get_result\r\nINTERNALERROR>     _reraise(*ex)  # noqa\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 264, in __init__\r\nINTERNALERROR>     self.result = func()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 596, in execute\r\nINTERNALERROR>     res = hook_impl.function(*args)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/runner.py\", line 65, in pytest_runtest_protocol\r\nINTERNALERROR>     runtestprotocol(item, nextitem=nextitem)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/runner.py\", line 75, in runtestprotocol\r\nINTERNALERROR>     reports.append(call_and_report(item, \"call\", log))\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/runner.py\", line 121, in call_and_report\r\nINTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 724, in __call__\r\nINTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 338, in _hookexec\r\nINTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 333, in <lambda>\r\nINTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 595, in execute\r\nINTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 249, in _wrapped_call\r\nINTERNALERROR>     wrap_controller.send(call_outcome)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/skipping.py\", line 170, in pytest_runtest_makereport\r\nINTERNALERROR>     rep = outcome.get_result()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 279, in get_result\r\nINTERNALERROR>     _reraise(*ex)  # noqa\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 264, in __init__\r\nINTERNALERROR>     self.result = func()\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py\", line 596, in execute\r\nINTERNALERROR>     res = hook_impl.function(*args)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/runner.py\", line 224, in pytest_runtest_makereport\r\nINTERNALERROR>     longrepr = item.repr_failure(excinfo)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/python.py\", line 751, in repr_failure\r\nINTERNALERROR>     return self._repr_failure_py(excinfo, style=style)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/python.py\", line 744, in _repr_failure_py\r\nINTERNALERROR>     style=style)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/_pytest/main.py\", line 404, in _repr_failure_py\r\nINTERNALERROR>     style=style, tbfilter=tbfilter)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_code/code.py\", line 412, in getrepr\r\nINTERNALERROR>     return fmt.repr_excinfo(self)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_code/code.py\", line 590, in repr_excinfo\r\nINTERNALERROR>     reprtraceback = self.repr_traceback(excinfo)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_code/code.py\", line 582, in repr_traceback\r\nINTERNALERROR>     reprentry = self.repr_traceback_entry(entry, einfo)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_code/code.py\", line 549, in repr_traceback_entry\r\nINTERNALERROR>     path = self._makepath(entry.path)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_code/code.py\", line 562, in _makepath\r\nINTERNALERROR>     np = py.path.local().bestrelpath(path)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_path/local.py\", line 149, in __init__\r\nINTERNALERROR>     self.strpath = py.error.checked_call(os.getcwd)\r\nINTERNALERROR>   File \"/nail/home/buck/trees/yelp/pip-faster/venv-venv_update/lib/python2.7/site-packages/py/_error.py\", line 84, in checked_call\r\nINTERNALERROR>     raise cls(\"%s%r\" % (func.__name__, args))\r\nINTERNALERROR> ENOENT: [No such file or directory]: getcwd()\r\n\r\n====================================================================================== no tests ran in 0.18 seconds =======================================================================================\r\n```"},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/comments/163358232","html_url":"https://github.com/pytest-dev/pytest/issues/1235#issuecomment-163358232","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1235","id":163358232,"user":{"login":"bukzor","id":640328,"avatar_url":"https://avatars.githubusercontent.com/u/640328?v=3","gravatar_id":"","url":"https://api.github.com/users/bukzor","html_url":"https://github.com/bukzor","followers_url":"https://api.github.com/users/bukzor/followers","following_url":"https://api.github.com/users/bukzor/following{/other_user}","gists_url":"https://api.github.com/users/bukzor/gists{/gist_id}","starred_url":"https://api.github.com/users/bukzor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bukzor/subscriptions","organizations_url":"https://api.github.com/users/bukzor/orgs","repos_url":"https://api.github.com/users/bukzor/repos","events_url":"https://api.github.com/users/bukzor/events{/privacy}","received_events_url":"https://api.github.com/users/bukzor/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T19:01:10Z","updated_at":"2015-12-09T19:01:10Z","body":"Full disclosure: I don't plan to work on this.\n\nI was able to find the rogue `path.chdir()` and changed it to `with\npath.as_cwd()` which enabled a good traceback.\n\nOn Tue, Dec 8, 2015 at 12:54 PM holger krekel <notifications@github.com>\nwrote:\n\n> agred, that's not robust behaviour. Also it's wrong for traceback\n> representation to use py.path.local(). Instead we should use the\n> \"startdir\" as it is stored on the terminal writer plugin (we can also put\n> it to the config object in addition or instead) for computing relative\n> paths. If we can merge Bruno's \"move py.code to pytest\" we could probably\n> more easily fix this properly.\n>\n> It's probably also possible to fix this in the pytest-2.8 series maybe by\n> e.g. changing to \"startdir\" before we call the pytest_runtest_makereport\n> hook. @bukzor <https://github.com/bukzor> if you feel like trying that in\n> a PR you are welcome (with a test which you basically already have) .\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/pytest-dev/pytest/issues/1235#issuecomment-163014925>.\n>\n"}}