{"action":"created","comment":{"url":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments/99189690","pull_request_review_id":19858770,"id":99189690,"diff_hunk":"@@ -1246,6 +1260,11 @@ def __exit__(self, *tp):\n         suppress_exception = issubclass(self.excinfo.type, self.expected_exception)\n         if sys.version_info[0] == 2 and suppress_exception:\n             sys.exc_clear()\n+        if self.match_expr:\n+            try:","path":"_pytest/python.py","position":61,"original_position":61,"commit_id":"3c4c6f0d89c0ed470f92a02784f109752ba04f91","original_commit_id":"79ec87f4d2e8772836c829010a6c11c97e8af4a5","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},"body":"I think just calling `self.excinfo.match` should be enough, as this will produce the same behavior as:\r\n\r\n```python\r\nwith pytest.raises(...) as excinfo:\r\n    func()\r\nexcinfo.match(text)\r\n```\r\n\r\nOr am I missing something?\r\n\r\nI guess one issue in that case is that the traceback will point to pytest's internals, but to prevent that we just need to declare a `__tracebackhide__` variable:\r\n\r\n```python\r\n__tracebackhide__ = True\r\nif self.match_expr:\r\n    self.excinfo.match(self.match_expr)\r\n```\r\n","created_at":"2017-02-02T18:41:08Z","updated_at":"2017-02-02T18:41:08Z","html_url":"https://github.com/pytest-dev/pytest/pull/2227#discussion_r99189690","pull_request_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227","_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/comments/99189690"},"html":{"href":"https://github.com/pytest-dev/pytest/pull/2227#discussion_r99189690"},"pull_request":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227"}}},"pull_request":{"url":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227","id":104128145,"html_url":"https://github.com/pytest-dev/pytest/pull/2227","diff_url":"https://github.com/pytest-dev/pytest/pull/2227.diff","patch_url":"https://github.com/pytest-dev/pytest/pull/2227.patch","issue_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2227","number":2227,"state":"open","locked":false,"title":"add matching the error message to pytest.raises","user":{"login":"Kriechi","id":114300,"avatar_url":"https://avatars.githubusercontent.com/u/114300?v=3","gravatar_id":"","url":"https://api.github.com/users/Kriechi","html_url":"https://github.com/Kriechi","followers_url":"https://api.github.com/users/Kriechi/followers","following_url":"https://api.github.com/users/Kriechi/following{/other_user}","gists_url":"https://api.github.com/users/Kriechi/gists{/gist_id}","starred_url":"https://api.github.com/users/Kriechi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kriechi/subscriptions","organizations_url":"https://api.github.com/users/Kriechi/orgs","repos_url":"https://api.github.com/users/Kriechi/repos","events_url":"https://api.github.com/users/Kriechi/events{/privacy}","received_events_url":"https://api.github.com/users/Kriechi/received_events","type":"User","site_admin":false},"body":"`pytest.raises` can now assert that the error message contains a certain text.\r\nExample:\r\n```python\r\nwith raises(ValueError, match_info='must be 0'):\r\n    raise ValueError(\"value must be 0 or None\")\r\n```\r\n\r\n\r\nThis is a more compact and IMHO cleaner way of doing it like this:\r\n```python\r\nwith raises(ValueError) as exc_info:\r\n    raise ValueError(\"value must be <= 10\")\r\nassert \"value must be <= 10\" in str(exc_info.value)\r\n```","created_at":"2017-02-01T12:37:49Z","updated_at":"2017-02-02T18:41:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51364f0733b1b5ae3d0e3a0a453f955e76cb4bed","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227/commits","review_comments_url":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227/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/2227/comments","statuses_url":"https://api.github.com/repos/pytest-dev/pytest/statuses/3c4c6f0d89c0ed470f92a02784f109752ba04f91","head":{"label":"Kriechi:raises-info","ref":"raises-info","sha":"3c4c6f0d89c0ed470f92a02784f109752ba04f91","user":{"login":"Kriechi","id":114300,"avatar_url":"https://avatars.githubusercontent.com/u/114300?v=3","gravatar_id":"","url":"https://api.github.com/users/Kriechi","html_url":"https://github.com/Kriechi","followers_url":"https://api.github.com/users/Kriechi/followers","following_url":"https://api.github.com/users/Kriechi/following{/other_user}","gists_url":"https://api.github.com/users/Kriechi/gists{/gist_id}","starred_url":"https://api.github.com/users/Kriechi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kriechi/subscriptions","organizations_url":"https://api.github.com/users/Kriechi/orgs","repos_url":"https://api.github.com/users/Kriechi/repos","events_url":"https://api.github.com/users/Kriechi/events{/privacy}","received_events_url":"https://api.github.com/users/Kriechi/received_events","type":"User","site_admin":false},"repo":{"id":80610256,"name":"pytest","full_name":"Kriechi/pytest","owner":{"login":"Kriechi","id":114300,"avatar_url":"https://avatars.githubusercontent.com/u/114300?v=3","gravatar_id":"","url":"https://api.github.com/users/Kriechi","html_url":"https://github.com/Kriechi","followers_url":"https://api.github.com/users/Kriechi/followers","following_url":"https://api.github.com/users/Kriechi/following{/other_user}","gists_url":"https://api.github.com/users/Kriechi/gists{/gist_id}","starred_url":"https://api.github.com/users/Kriechi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kriechi/subscriptions","organizations_url":"https://api.github.com/users/Kriechi/orgs","repos_url":"https://api.github.com/users/Kriechi/repos","events_url":"https://api.github.com/users/Kriechi/events{/privacy}","received_events_url":"https://api.github.com/users/Kriechi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kriechi/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/Kriechi/pytest","forks_url":"https://api.github.com/repos/Kriechi/pytest/forks","keys_url":"https://api.github.com/repos/Kriechi/pytest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kriechi/pytest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kriechi/pytest/teams","hooks_url":"https://api.github.com/repos/Kriechi/pytest/hooks","issue_events_url":"https://api.github.com/repos/Kriechi/pytest/issues/events{/number}","events_url":"https://api.github.com/repos/Kriechi/pytest/events","assignees_url":"https://api.github.com/repos/Kriechi/pytest/assignees{/user}","branches_url":"https://api.github.com/repos/Kriechi/pytest/branches{/branch}","tags_url":"https://api.github.com/repos/Kriechi/pytest/tags","blobs_url":"https://api.github.com/repos/Kriechi/pytest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kriechi/pytest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kriechi/pytest/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kriechi/pytest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kriechi/pytest/statuses/{sha}","languages_url":"https://api.github.com/repos/Kriechi/pytest/languages","stargazers_url":"https://api.github.com/repos/Kriechi/pytest/stargazers","contributors_url":"https://api.github.com/repos/Kriechi/pytest/contributors","subscribers_url":"https://api.github.com/repos/Kriechi/pytest/subscribers","subscription_url":"https://api.github.com/repos/Kriechi/pytest/subscription","commits_url":"https://api.github.com/repos/Kriechi/pytest/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kriechi/pytest/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kriechi/pytest/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kriechi/pytest/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kriechi/pytest/contents/{+path}","compare_url":"https://api.github.com/repos/Kriechi/pytest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kriechi/pytest/merges","archive_url":"https://api.github.com/repos/Kriechi/pytest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kriechi/pytest/downloads","issues_url":"https://api.github.com/repos/Kriechi/pytest/issues{/number}","pulls_url":"https://api.github.com/repos/Kriechi/pytest/pulls{/number}","milestones_url":"https://api.github.com/repos/Kriechi/pytest/milestones{/number}","notifications_url":"https://api.github.com/repos/Kriechi/pytest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kriechi/pytest/labels{/name}","releases_url":"https://api.github.com/repos/Kriechi/pytest/releases{/id}","deployments_url":"https://api.github.com/repos/Kriechi/pytest/deployments","created_at":"2017-02-01T10:35:48Z","updated_at":"2017-02-01T10:35:50Z","pushed_at":"2017-02-02T18:26:43Z","git_url":"git://github.com/Kriechi/pytest.git","ssh_url":"git@github.com:Kriechi/pytest.git","clone_url":"https://github.com/Kriechi/pytest.git","svn_url":"https://github.com/Kriechi/pytest","homepage":"http://pytest.org/","size":9205,"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":"3b47cb45e6e442a4a45934b4d885be12191c2358","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":"2017-02-02T18:19:30Z","pushed_at":"2017-02-02T18:26:45Z","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":9148,"stargazers_count":1179,"watchers_count":1179,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":315,"mirror_url":null,"open_issues_count":313,"forks":315,"open_issues":313,"watchers":1179,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227"},"html":{"href":"https://github.com/pytest-dev/pytest/pull/2227"},"issue":{"href":"https://api.github.com/repos/pytest-dev/pytest/issues/2227"},"comments":{"href":"https://api.github.com/repos/pytest-dev/pytest/issues/2227/comments"},"review_comments":{"href":"https://api.github.com/repos/pytest-dev/pytest/pulls/2227/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/2227/commits"},"statuses":{"href":"https://api.github.com/repos/pytest-dev/pytest/statuses/3c4c6f0d89c0ed470f92a02784f109752ba04f91"}}}}
{"actor":{"display_login":"nicoddemus"}}