{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/1493","repository_url":"https://api.github.com/repos/pytest-dev/pytest","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1493/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1493/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1493/events","html_url":"https://github.com/pytest-dev/pytest/issues/1493","id":144584795,"number":1493,"title":"Use test body as traceback when empty","user":{"login":"max4t","id":2833969,"avatar_url":"https://avatars.githubusercontent.com/u/2833969?v=3","gravatar_id":"","url":"https://api.github.com/users/max4t","html_url":"https://github.com/max4t","followers_url":"https://api.github.com/users/max4t/followers","following_url":"https://api.github.com/users/max4t/following{/other_user}","gists_url":"https://api.github.com/users/max4t/gists{/gist_id}","starred_url":"https://api.github.com/users/max4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/max4t/subscriptions","organizations_url":"https://api.github.com/users/max4t/orgs","repos_url":"https://api.github.com/users/max4t/repos","events_url":"https://api.github.com/users/max4t/events{/privacy}","received_events_url":"https://api.github.com/users/max4t/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-30T13:13:47Z","updated_at":"2016-03-30T16:20:16Z","closed_at":"2016-03-30T16:20:15Z","body":"Hi,\r\nI've added a 'raises' marker for my tests and to handle these, i've created a runtest wrapper like this:\r\n\r\n```python\r\n@pytest.hookimpl(hookwrapper=True)\r\ndef pytest_runtest_call(item):\r\n    #__tracebackhide__ = True\r\n    if item.get_marker(\"raises\"):\r\n        with pytest.raises(item.get_marker(\"raises\").kwargs['error']):\r\n            outcome = (yield)\r\n            outcome.get_result()\r\n        outcome.force_result(None)\r\n    else:\r\n        yield\r\n```\r\n\r\nIt works fine except for the traceback because if the test did not raise any exception, it's not in the trace anymore and the trace of the wrapper will be printed instead.\r\nIf i use the '\\_\\_tracebackhide\\_\\_' variable to ignore the trace of the wrapper, the traceback is empty which raise an error like this:\r\n\r\n```\r\n.......\r\n  File \"./venv/lib/python3.4/site-packages/_pytest/_code/code.py\", line 418, in getrepr\r\n    return fmt.repr_excinfo(self)\r\n  File \"./venv/lib/python3.4/site-packages/_pytest/_code/code.py\", line 598, in repr_excinfo\r\n    reprtraceback = self.repr_traceback(excinfo)\r\n  File \"./venv/lib/python3.4/site-packages/_pytest/_code/code.py\", line 585, in repr_traceback\r\n    last = traceback[-1]\r\n  File \"./venv/lib/python3.4/site-packages/_pytest/_code/code.py\", line 289, in __getitem__\r\n    val = super(Traceback, self).__getitem__(key)\r\nIndexError: list index out of range\r\n```\r\n\r\nWouldn't it be useful to print the test body as traceback if it's empty? Instead of printing the pytest_runtest_call body (without \\_\\_tracebackhide\\_\\_) or raising an error (with \\_\\_tracebackhide\\_\\_).\r\n\r\nIt would be useful to mark cases of a parametrized test."},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/comments/203510845","html_url":"https://github.com/pytest-dev/pytest/issues/1493#issuecomment-203510845","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1493","id":203510845,"user":{"login":"nicoddemus","id":1085180,"avatar_url":"https://avatars.githubusercontent.com/u/1085180?v=3","gravatar_id":"","url":"https://api.github.com/users/nicoddemus","html_url":"https://github.com/nicoddemus","followers_url":"https://api.github.com/users/nicoddemus/followers","following_url":"https://api.github.com/users/nicoddemus/following{/other_user}","gists_url":"https://api.github.com/users/nicoddemus/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoddemus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoddemus/subscriptions","organizations_url":"https://api.github.com/users/nicoddemus/orgs","repos_url":"https://api.github.com/users/nicoddemus/repos","events_url":"https://api.github.com/users/nicoddemus/events{/privacy}","received_events_url":"https://api.github.com/users/nicoddemus/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T16:20:15Z","updated_at":"2016-03-30T16:20:15Z","body":"Thanks, closing as duplicate of #905 (added your suggestion there as well)."}}