{"action":"created","comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments/67722980","id":67722980,"diff_hunk":"@@ -76,3 +76,23 @@ def test_no_raise_message(self):\n             pytest.raises(ValueError, int, '0')\n         except pytest.raises.Exception as e:\n             assert e.msg == \"DID NOT RAISE {0}\".format(repr(ValueError))\n+        else:\n+            assert False, \"Expected pytest.raises.Exception\"\n+\n+        try:\n+            with pytest.raises(ValueError):\n+                pass\n+        except pytest.raises.Exception as e:\n+            assert e.msg == \"DID NOT RAISE {0}\".format(repr(ValueError))\n+        else:\n+            assert False, \"Expected pytest.raises.Exception\"\n+\n+    def test_costum_raise_message(self):","path":"testing/python/raises.py","position":15,"original_position":15,"commit_id":"f8d4cadc3d5d9145d7be1d462fd6b1135307fd5f","original_commit_id":"f8d4cadc3d5d9145d7be1d462fd6b1135307fd5f","user":{"login":"The-Compiler","id":625793,"avatar_url":"https://avatars.githubusercontent.com/u/625793?v=3","gravatar_id":"","url":"https://api.github.com/users/The-Compiler","html_url":"https://github.com/The-Compiler","followers_url":"https://api.github.com/users/The-Compiler/followers","following_url":"https://api.github.com/users/The-Compiler/following{/other_user}","gists_url":"https://api.github.com/users/The-Compiler/gists{/gist_id}","starred_url":"https://api.github.com/users/The-Compiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/The-Compiler/subscriptions","organizations_url":"https://api.github.com/users/The-Compiler/orgs","repos_url":"https://api.github.com/users/The-Compiler/repos","events_url":"https://api.github.com/users/The-Compiler/events{/privacy}","received_events_url":"https://api.github.com/users/The-Compiler/received_events","type":"User","site_admin":false},"body":"costum -> custom, but I'll fix it up when merging","created_at":"2016-06-20T16:42:32Z","updated_at":"2016-06-20T16:42:32Z","html_url":"https://github.com/pytest-dev/pytest/pull/1616#discussion_r67722980","pull_request_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616","_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments/67722980"},"html":{"href":"https://github.com/pytest-dev/pytest/pull/1616#discussion_r67722980"},"pull_request":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616"}}},"pull_request":{"url":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616","id":74121586,"html_url":"https://github.com/pytest-dev/pytest/pull/1616","diff_url":"https://github.com/pytest-dev/pytest/pull/1616.diff","patch_url":"https://github.com/pytest-dev/pytest/pull/1616.patch","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1616","number":1616,"state":"open","locked":false,"title":"Pytest.raises custom error message","user":{"login":"palaviv","id":6990375,"avatar_url":"https://avatars.githubusercontent.com/u/6990375?v=3","gravatar_id":"","url":"https://api.github.com/users/palaviv","html_url":"https://github.com/palaviv","followers_url":"https://api.github.com/users/palaviv/followers","following_url":"https://api.github.com/users/palaviv/following{/other_user}","gists_url":"https://api.github.com/users/palaviv/gists{/gist_id}","starred_url":"https://api.github.com/users/palaviv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palaviv/subscriptions","organizations_url":"https://api.github.com/users/palaviv/orgs","repos_url":"https://api.github.com/users/palaviv/repos","events_url":"https://api.github.com/users/palaviv/events{/privacy}","received_events_url":"https://api.github.com/users/palaviv/received_events","type":"User","site_admin":false},"body":"This PR change pytest.raises to accept custom made message that will be raised if no exception was raised. For example:\r\n\r\n```py\r\nwith pytest.raises(KeyError, message=\"I am expecting a KeyError to be raised\"):\r\n    pass\r\nFailed: I am expecting a KeyError to be raised\r\n```\r\n\r\nThe use case behind this feature is as follows:\r\n\r\n```py\r\nfor i in random.shuffle([\"a\", \"b\", \"c\"]):\r\n   with pytest.raises(KeyError):\r\n        if i == \"b\":\r\n            raise KeyError\r\n```\r\n\r\nAs you can see in this example I can't know at which ``input`` I have failed from the result of the test. The new message will allow me to change the test as follows:\r\n\r\n ```py\r\nfor input in random.shuffle([\"a\", \"b\", \"c\"]):\r\n   with pytest.raises(KeyError, message=\"Key error was not raised for input {}\".format(i)):\r\n        if input == \"b\":\r\n            raise KeyError\r\n```\r\n\r\nNow I can know the exact ``input`` the test failed.","created_at":"2016-06-16T17:36:26Z","updated_at":"2016-06-20T16:42:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a426d96592a28249281fb58b9ee3c369c6cb7344","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616/commits","review_comments_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616/comments","review_comment_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/1616/comments","statuses_url":"https://api.github.com/repos/pytest-dev/pytest/statuses/f8d4cadc3d5d9145d7be1d462fd6b1135307fd5f","head":{"label":"palaviv:pytest.raises-message","ref":"pytest.raises-message","sha":"f8d4cadc3d5d9145d7be1d462fd6b1135307fd5f","user":{"login":"palaviv","id":6990375,"avatar_url":"https://avatars.githubusercontent.com/u/6990375?v=3","gravatar_id":"","url":"https://api.github.com/users/palaviv","html_url":"https://github.com/palaviv","followers_url":"https://api.github.com/users/palaviv/followers","following_url":"https://api.github.com/users/palaviv/following{/other_user}","gists_url":"https://api.github.com/users/palaviv/gists{/gist_id}","starred_url":"https://api.github.com/users/palaviv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palaviv/subscriptions","organizations_url":"https://api.github.com/users/palaviv/orgs","repos_url":"https://api.github.com/users/palaviv/repos","events_url":"https://api.github.com/users/palaviv/events{/privacy}","received_events_url":"https://api.github.com/users/palaviv/received_events","type":"User","site_admin":false},"repo":{"id":53679914,"name":"pytest","full_name":"palaviv/pytest","owner":{"login":"palaviv","id":6990375,"avatar_url":"https://avatars.githubusercontent.com/u/6990375?v=3","gravatar_id":"","url":"https://api.github.com/users/palaviv","html_url":"https://github.com/palaviv","followers_url":"https://api.github.com/users/palaviv/followers","following_url":"https://api.github.com/users/palaviv/following{/other_user}","gists_url":"https://api.github.com/users/palaviv/gists{/gist_id}","starred_url":"https://api.github.com/users/palaviv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palaviv/subscriptions","organizations_url":"https://api.github.com/users/palaviv/orgs","repos_url":"https://api.github.com/users/palaviv/repos","events_url":"https://api.github.com/users/palaviv/events{/privacy}","received_events_url":"https://api.github.com/users/palaviv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/palaviv/pytest","description":"The pytest framework makes it easy to write small tests, yet scales to support complex functional testing","fork":true,"url":"https://api.github.com/repos/palaviv/pytest","forks_url":"https://api.github.com/repos/palaviv/pytest/forks","keys_url":"https://api.github.com/repos/palaviv/pytest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palaviv/pytest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palaviv/pytest/teams","hooks_url":"https://api.github.com/repos/palaviv/pytest/hooks","issue_events_url":"https://api.github.com/repos/palaviv/pytest/issues/events{/number}","events_url":"https://api.github.com/repos/palaviv/pytest/events","assignees_url":"https://api.github.com/repos/palaviv/pytest/assignees{/user}","branches_url":"https://api.github.com/repos/palaviv/pytest/branches{/branch}","tags_url":"https://api.github.com/repos/palaviv/pytest/tags","blobs_url":"https://api.github.com/repos/palaviv/pytest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palaviv/pytest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palaviv/pytest/git/refs{/sha}","trees_url":"https://api.github.com/repos/palaviv/pytest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palaviv/pytest/statuses/{sha}","languages_url":"https://api.github.com/repos/palaviv/pytest/languages","stargazers_url":"https://api.github.com/repos/palaviv/pytest/stargazers","contributors_url":"https://api.github.com/repos/palaviv/pytest/contributors","subscribers_url":"https://api.github.com/repos/palaviv/pytest/subscribers","subscription_url":"https://api.github.com/repos/palaviv/pytest/subscription","commits_url":"https://api.github.com/repos/palaviv/pytest/commits{/sha}","git_commits_url":"https://api.github.com/repos/palaviv/pytest/git/commits{/sha}","comments_url":"https://api.github.com/repos/palaviv/pytest/comments{/number}","issue_comment_url":"https://api.github.com/repos/palaviv/pytest/issues/comments{/number}","contents_url":"https://api.github.com/repos/palaviv/pytest/contents/{+path}","compare_url":"https://api.github.com/repos/palaviv/pytest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palaviv/pytest/merges","archive_url":"https://api.github.com/repos/palaviv/pytest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palaviv/pytest/downloads","issues_url":"https://api.github.com/repos/palaviv/pytest/issues{/number}","pulls_url":"https://api.github.com/repos/palaviv/pytest/pulls{/number}","milestones_url":"https://api.github.com/repos/palaviv/pytest/milestones{/number}","notifications_url":"https://api.github.com/repos/palaviv/pytest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palaviv/pytest/labels{/name}","releases_url":"https://api.github.com/repos/palaviv/pytest/releases{/id}","deployments_url":"https://api.github.com/repos/palaviv/pytest/deployments","created_at":"2016-03-11T16:18:12Z","updated_at":"2016-03-11T16:18:13Z","pushed_at":"2016-06-19T20:56:47Z","git_url":"git://github.com/palaviv/pytest.git","ssh_url":"git@github.com:palaviv/pytest.git","clone_url":"https://github.com/palaviv/pytest.git","svn_url":"https://github.com/palaviv/pytest","homepage":"http://pytest.org/","size":7844,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pytest-dev:features","ref":"features","sha":"308396ae3c8c751176a151e2e9daf9b0772cd679","user":{"login":"pytest-dev","id":8897583,"avatar_url":"https://avatars.githubusercontent.com/u/8897583?v=3","gravatar_id":"","url":"https://api.github.com/users/pytest-dev","html_url":"https://github.com/pytest-dev","followers_url":"https://api.github.com/users/pytest-dev/followers","following_url":"https://api.github.com/users/pytest-dev/following{/other_user}","gists_url":"https://api.github.com/users/pytest-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/pytest-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytest-dev/subscriptions","organizations_url":"https://api.github.com/users/pytest-dev/orgs","repos_url":"https://api.github.com/users/pytest-dev/repos","events_url":"https://api.github.com/users/pytest-dev/events{/privacy}","received_events_url":"https://api.github.com/users/pytest-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":37489525,"name":"pytest","full_name":"pytest-dev/pytest","owner":{"login":"pytest-dev","id":8897583,"avatar_url":"https://avatars.githubusercontent.com/u/8897583?v=3","gravatar_id":"","url":"https://api.github.com/users/pytest-dev","html_url":"https://github.com/pytest-dev","followers_url":"https://api.github.com/users/pytest-dev/followers","following_url":"https://api.github.com/users/pytest-dev/following{/other_user}","gists_url":"https://api.github.com/users/pytest-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/pytest-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pytest-dev/subscriptions","organizations_url":"https://api.github.com/users/pytest-dev/orgs","repos_url":"https://api.github.com/users/pytest-dev/repos","events_url":"https://api.github.com/users/pytest-dev/events{/privacy}","received_events_url":"https://api.github.com/users/pytest-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pytest-dev/pytest","description":"The pytest framework makes it easy to write small tests, yet scales to support complex functional testing","fork":false,"url":"https://api.github.com/repos/pytest-dev/pytest","forks_url":"https://api.github.com/repos/pytest-dev/pytest/forks","keys_url":"https://api.github.com/repos/pytest-dev/pytest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytest-dev/pytest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytest-dev/pytest/teams","hooks_url":"https://api.github.com/repos/pytest-dev/pytest/hooks","issue_events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/events{/number}","events_url":"https://api.github.com/repos/pytest-dev/pytest/events","assignees_url":"https://api.github.com/repos/pytest-dev/pytest/assignees{/user}","branches_url":"https://api.github.com/repos/pytest-dev/pytest/branches{/branch}","tags_url":"https://api.github.com/repos/pytest-dev/pytest/tags","blobs_url":"https://api.github.com/repos/pytest-dev/pytest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytest-dev/pytest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytest-dev/pytest/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytest-dev/pytest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytest-dev/pytest/statuses/{sha}","languages_url":"https://api.github.com/repos/pytest-dev/pytest/languages","stargazers_url":"https://api.github.com/repos/pytest-dev/pytest/stargazers","contributors_url":"https://api.github.com/repos/pytest-dev/pytest/contributors","subscribers_url":"https://api.github.com/repos/pytest-dev/pytest/subscribers","subscription_url":"https://api.github.com/repos/pytest-dev/pytest/subscription","commits_url":"https://api.github.com/repos/pytest-dev/pytest/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytest-dev/pytest/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytest-dev/pytest/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytest-dev/pytest/contents/{+path}","compare_url":"https://api.github.com/repos/pytest-dev/pytest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytest-dev/pytest/merges","archive_url":"https://api.github.com/repos/pytest-dev/pytest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytest-dev/pytest/downloads","issues_url":"https://api.github.com/repos/pytest-dev/pytest/issues{/number}","pulls_url":"https://api.github.com/repos/pytest-dev/pytest/pulls{/number}","milestones_url":"https://api.github.com/repos/pytest-dev/pytest/milestones{/number}","notifications_url":"https://api.github.com/repos/pytest-dev/pytest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytest-dev/pytest/labels{/name}","releases_url":"https://api.github.com/repos/pytest-dev/pytest/releases{/id}","deployments_url":"https://api.github.com/repos/pytest-dev/pytest/deployments","created_at":"2015-06-15T20:28:27Z","updated_at":"2016-06-20T04:26:23Z","pushed_at":"2016-06-20T16:14:06Z","git_url":"git://github.com/pytest-dev/pytest.git","ssh_url":"git@github.com:pytest-dev/pytest.git","clone_url":"https://github.com/pytest-dev/pytest.git","svn_url":"https://github.com/pytest-dev/pytest","homepage":"http://pytest.org/","size":9820,"stargazers_count":737,"watchers_count":737,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":188,"mirror_url":null,"open_issues_count":323,"forks":188,"open_issues":323,"watchers":737,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616"},"html":{"href":"https://github.com/pytest-dev/pytest/pull/1616"},"issue":{"href":"https://api.github.com/repos/pytest-dev/pytest/issues/1616"},"comments":{"href":"https://api.github.com/repos/pytest-dev/pytest/issues/1616/comments"},"review_comments":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616/comments"},"review_comment":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/1616/commits"},"statuses":{"href":"https://api.github.com/repos/pytest-dev/pytest/statuses/f8d4cadc3d5d9145d7be1d462fd6b1135307fd5f"}}}}
{"actor":{"display_login":"The-Compiler"}}