{"action":"created","comment":{"url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/comments/60155172","id":60155172,"diff_hunk":"@@ -147,3 +147,18 @@ def test_unicode_handling(self):\n         self.assertEqual(str(poop_okra), \"Okra💩\")\n         if not PY3:\n             self.assertEqual(unicode(poop_okra), u\"Okra💩\")\n+\n+    def test_specific_lookup_error_is_caught(self):\n+        with self.assertRaises(Vegetable.LookupError):\n+            Vegetable.lookup('canonical_name', 'meat')\n+\n+    def test_other_specific_lookup_error_is_not_caught(self):\n+        class Meat(RichEnum):\n+            COW = RichEnumValue(\"cow\", \"Cow\")\n+\n+        try:","path":"tests/richenum/test_rich_enums.py","position":13,"original_position":13,"commit_id":"117c8208bdbf995dcd76b37af8ecbf1e8a4453a3","original_commit_id":"117c8208bdbf995dcd76b37af8ecbf1e8a4453a3","user":{"login":"dhui","id":896205,"avatar_url":"https://avatars.githubusercontent.com/u/896205?v=3","gravatar_id":"","url":"https://api.github.com/users/dhui","html_url":"https://github.com/dhui","followers_url":"https://api.github.com/users/dhui/followers","following_url":"https://api.github.com/users/dhui/following{/other_user}","gists_url":"https://api.github.com/users/dhui/gists{/gist_id}","starred_url":"https://api.github.com/users/dhui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhui/subscriptions","organizations_url":"https://api.github.com/users/dhui/orgs","repos_url":"https://api.github.com/users/dhui/repos","events_url":"https://api.github.com/users/dhui/events{/privacy}","received_events_url":"https://api.github.com/users/dhui/received_events","type":"User","site_admin":false},"body":"Yeah, but this test is a bit more fragile as depends on the ordering of the `except` clauses.\r\nIt's also testing exception behavior documented in Python which doesn't need to be tested (unless the behavior changes between Python versions).\r\n\r\nFrom the Python 2.7.11 docs:\r\n\r\n> For an except clause with an expression, that expression is evaluated, and the clause matches the exception if the resulting object is “compatible” with the exception. An object is compatible with an exception if it is the class or a base class of the exception object, or a tuple containing an item compatible with the exception.\r\n\r\nhttps://docs.python.org/2/reference/compound_stmts.html#except\r\n\r\nSo to check that a `Meat.LookupError` won't be caught by a `<NonMeat>.LookupError`, checking the exception's hierarchy is sufficient.","created_at":"2016-04-19T00:02:17Z","updated_at":"2016-04-19T00:02:18Z","html_url":"https://github.com/hearsaycorp/richenum/pull/39#discussion_r60155172","pull_request_url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/comments/60155172"},"html":{"href":"https://github.com/hearsaycorp/richenum/pull/39#discussion_r60155172"},"pull_request":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39","id":66701786,"html_url":"https://github.com/hearsaycorp/richenum/pull/39","diff_url":"https://github.com/hearsaycorp/richenum/pull/39.diff","patch_url":"https://github.com/hearsaycorp/richenum/pull/39.patch","issue_url":"https://api.github.com/repos/hearsaycorp/richenum/issues/39","number":39,"state":"open","locked":false,"title":"Add LookupError members to RichEnums to simply catching lookup errors, and bump version to 1.2","user":{"login":"rbm","id":35633,"avatar_url":"https://avatars.githubusercontent.com/u/35633?v=3","gravatar_id":"","url":"https://api.github.com/users/rbm","html_url":"https://github.com/rbm","followers_url":"https://api.github.com/users/rbm/followers","following_url":"https://api.github.com/users/rbm/following{/other_user}","gists_url":"https://api.github.com/users/rbm/gists{/gist_id}","starred_url":"https://api.github.com/users/rbm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbm/subscriptions","organizations_url":"https://api.github.com/users/rbm/orgs","repos_url":"https://api.github.com/users/rbm/repos","events_url":"https://api.github.com/users/rbm/events{/privacy}","received_events_url":"https://api.github.com/users/rbm/received_events","type":"User","site_admin":false},"body":"Similar to how `DoesNotExist` works in Django, etc, add a type-specific `EnumLookupError` subclass to each constructed `RichEnum`-derived class, so\r\nthat\r\n1) Users can avoid having to import `EnumLookupError` specifically\r\n2) Users can choose to catch `LookupError`s for only specific enums\r\n\r\nAlso added tests.\r\n","created_at":"2016-04-15T20:41:21Z","updated_at":"2016-04-19T00:02:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0441c1eb4a7da1776ec80156cdaaf0e3fc7a28df","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39/commits","review_comments_url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39/comments","review_comment_url":"https://api.github.com/repos/hearsaycorp/richenum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hearsaycorp/richenum/issues/39/comments","statuses_url":"https://api.github.com/repos/hearsaycorp/richenum/statuses/117c8208bdbf995dcd76b37af8ecbf1e8a4453a3","head":{"label":"rbm:convenient-exceptions","ref":"convenient-exceptions","sha":"117c8208bdbf995dcd76b37af8ecbf1e8a4453a3","user":{"login":"rbm","id":35633,"avatar_url":"https://avatars.githubusercontent.com/u/35633?v=3","gravatar_id":"","url":"https://api.github.com/users/rbm","html_url":"https://github.com/rbm","followers_url":"https://api.github.com/users/rbm/followers","following_url":"https://api.github.com/users/rbm/following{/other_user}","gists_url":"https://api.github.com/users/rbm/gists{/gist_id}","starred_url":"https://api.github.com/users/rbm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbm/subscriptions","organizations_url":"https://api.github.com/users/rbm/orgs","repos_url":"https://api.github.com/users/rbm/repos","events_url":"https://api.github.com/users/rbm/events{/privacy}","received_events_url":"https://api.github.com/users/rbm/received_events","type":"User","site_admin":false},"repo":{"id":13047980,"name":"richenum","full_name":"rbm/richenum","owner":{"login":"rbm","id":35633,"avatar_url":"https://avatars.githubusercontent.com/u/35633?v=3","gravatar_id":"","url":"https://api.github.com/users/rbm","html_url":"https://github.com/rbm","followers_url":"https://api.github.com/users/rbm/followers","following_url":"https://api.github.com/users/rbm/following{/other_user}","gists_url":"https://api.github.com/users/rbm/gists{/gist_id}","starred_url":"https://api.github.com/users/rbm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbm/subscriptions","organizations_url":"https://api.github.com/users/rbm/orgs","repos_url":"https://api.github.com/users/rbm/repos","events_url":"https://api.github.com/users/rbm/events{/privacy}","received_events_url":"https://api.github.com/users/rbm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rbm/richenum","description":"","fork":true,"url":"https://api.github.com/repos/rbm/richenum","forks_url":"https://api.github.com/repos/rbm/richenum/forks","keys_url":"https://api.github.com/repos/rbm/richenum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rbm/richenum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rbm/richenum/teams","hooks_url":"https://api.github.com/repos/rbm/richenum/hooks","issue_events_url":"https://api.github.com/repos/rbm/richenum/issues/events{/number}","events_url":"https://api.github.com/repos/rbm/richenum/events","assignees_url":"https://api.github.com/repos/rbm/richenum/assignees{/user}","branches_url":"https://api.github.com/repos/rbm/richenum/branches{/branch}","tags_url":"https://api.github.com/repos/rbm/richenum/tags","blobs_url":"https://api.github.com/repos/rbm/richenum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rbm/richenum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rbm/richenum/git/refs{/sha}","trees_url":"https://api.github.com/repos/rbm/richenum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rbm/richenum/statuses/{sha}","languages_url":"https://api.github.com/repos/rbm/richenum/languages","stargazers_url":"https://api.github.com/repos/rbm/richenum/stargazers","contributors_url":"https://api.github.com/repos/rbm/richenum/contributors","subscribers_url":"https://api.github.com/repos/rbm/richenum/subscribers","subscription_url":"https://api.github.com/repos/rbm/richenum/subscription","commits_url":"https://api.github.com/repos/rbm/richenum/commits{/sha}","git_commits_url":"https://api.github.com/repos/rbm/richenum/git/commits{/sha}","comments_url":"https://api.github.com/repos/rbm/richenum/comments{/number}","issue_comment_url":"https://api.github.com/repos/rbm/richenum/issues/comments{/number}","contents_url":"https://api.github.com/repos/rbm/richenum/contents/{+path}","compare_url":"https://api.github.com/repos/rbm/richenum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rbm/richenum/merges","archive_url":"https://api.github.com/repos/rbm/richenum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rbm/richenum/downloads","issues_url":"https://api.github.com/repos/rbm/richenum/issues{/number}","pulls_url":"https://api.github.com/repos/rbm/richenum/pulls{/number}","milestones_url":"https://api.github.com/repos/rbm/richenum/milestones{/number}","notifications_url":"https://api.github.com/repos/rbm/richenum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rbm/richenum/labels{/name}","releases_url":"https://api.github.com/repos/rbm/richenum/releases{/id}","deployments_url":"https://api.github.com/repos/rbm/richenum/deployments","created_at":"2013-09-23T21:40:59Z","updated_at":"2013-11-05T21:17:32Z","pushed_at":"2016-04-15T20:53:27Z","git_url":"git://github.com/rbm/richenum.git","ssh_url":"git@github.com:rbm/richenum.git","clone_url":"https://github.com/rbm/richenum.git","svn_url":"https://github.com/rbm/richenum","homepage":null,"size":74,"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":"hearsaycorp:master","ref":"master","sha":"3a22cdefb9b35666f9b68d07820c01abb8a1f380","user":{"login":"hearsaycorp","id":633032,"avatar_url":"https://avatars.githubusercontent.com/u/633032?v=3","gravatar_id":"","url":"https://api.github.com/users/hearsaycorp","html_url":"https://github.com/hearsaycorp","followers_url":"https://api.github.com/users/hearsaycorp/followers","following_url":"https://api.github.com/users/hearsaycorp/following{/other_user}","gists_url":"https://api.github.com/users/hearsaycorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hearsaycorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hearsaycorp/subscriptions","organizations_url":"https://api.github.com/users/hearsaycorp/orgs","repos_url":"https://api.github.com/users/hearsaycorp/repos","events_url":"https://api.github.com/users/hearsaycorp/events{/privacy}","received_events_url":"https://api.github.com/users/hearsaycorp/received_events","type":"Organization","site_admin":false},"repo":{"id":11711815,"name":"richenum","full_name":"hearsaycorp/richenum","owner":{"login":"hearsaycorp","id":633032,"avatar_url":"https://avatars.githubusercontent.com/u/633032?v=3","gravatar_id":"","url":"https://api.github.com/users/hearsaycorp","html_url":"https://github.com/hearsaycorp","followers_url":"https://api.github.com/users/hearsaycorp/followers","following_url":"https://api.github.com/users/hearsaycorp/following{/other_user}","gists_url":"https://api.github.com/users/hearsaycorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hearsaycorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hearsaycorp/subscriptions","organizations_url":"https://api.github.com/users/hearsaycorp/orgs","repos_url":"https://api.github.com/users/hearsaycorp/repos","events_url":"https://api.github.com/users/hearsaycorp/events{/privacy}","received_events_url":"https://api.github.com/users/hearsaycorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hearsaycorp/richenum","description":"A powerful enum library for Python.","fork":false,"url":"https://api.github.com/repos/hearsaycorp/richenum","forks_url":"https://api.github.com/repos/hearsaycorp/richenum/forks","keys_url":"https://api.github.com/repos/hearsaycorp/richenum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hearsaycorp/richenum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hearsaycorp/richenum/teams","hooks_url":"https://api.github.com/repos/hearsaycorp/richenum/hooks","issue_events_url":"https://api.github.com/repos/hearsaycorp/richenum/issues/events{/number}","events_url":"https://api.github.com/repos/hearsaycorp/richenum/events","assignees_url":"https://api.github.com/repos/hearsaycorp/richenum/assignees{/user}","branches_url":"https://api.github.com/repos/hearsaycorp/richenum/branches{/branch}","tags_url":"https://api.github.com/repos/hearsaycorp/richenum/tags","blobs_url":"https://api.github.com/repos/hearsaycorp/richenum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hearsaycorp/richenum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hearsaycorp/richenum/git/refs{/sha}","trees_url":"https://api.github.com/repos/hearsaycorp/richenum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hearsaycorp/richenum/statuses/{sha}","languages_url":"https://api.github.com/repos/hearsaycorp/richenum/languages","stargazers_url":"https://api.github.com/repos/hearsaycorp/richenum/stargazers","contributors_url":"https://api.github.com/repos/hearsaycorp/richenum/contributors","subscribers_url":"https://api.github.com/repos/hearsaycorp/richenum/subscribers","subscription_url":"https://api.github.com/repos/hearsaycorp/richenum/subscription","commits_url":"https://api.github.com/repos/hearsaycorp/richenum/commits{/sha}","git_commits_url":"https://api.github.com/repos/hearsaycorp/richenum/git/commits{/sha}","comments_url":"https://api.github.com/repos/hearsaycorp/richenum/comments{/number}","issue_comment_url":"https://api.github.com/repos/hearsaycorp/richenum/issues/comments{/number}","contents_url":"https://api.github.com/repos/hearsaycorp/richenum/contents/{+path}","compare_url":"https://api.github.com/repos/hearsaycorp/richenum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hearsaycorp/richenum/merges","archive_url":"https://api.github.com/repos/hearsaycorp/richenum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hearsaycorp/richenum/downloads","issues_url":"https://api.github.com/repos/hearsaycorp/richenum/issues{/number}","pulls_url":"https://api.github.com/repos/hearsaycorp/richenum/pulls{/number}","milestones_url":"https://api.github.com/repos/hearsaycorp/richenum/milestones{/number}","notifications_url":"https://api.github.com/repos/hearsaycorp/richenum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hearsaycorp/richenum/labels{/name}","releases_url":"https://api.github.com/repos/hearsaycorp/richenum/releases{/id}","deployments_url":"https://api.github.com/repos/hearsaycorp/richenum/deployments","created_at":"2013-07-27T22:17:47Z","updated_at":"2016-02-11T18:25:45Z","pushed_at":"2016-04-15T20:53:28Z","git_url":"git://github.com/hearsaycorp/richenum.git","ssh_url":"git@github.com:hearsaycorp/richenum.git","clone_url":"https://github.com/hearsaycorp/richenum.git","svn_url":"https://github.com/hearsaycorp/richenum","homepage":"http://engineering.hearsaysocial.com/2013/09/16/enums-in-python/","size":80,"stargazers_count":11,"watchers_count":11,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":1,"forks":12,"open_issues":1,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39"},"html":{"href":"https://github.com/hearsaycorp/richenum/pull/39"},"issue":{"href":"https://api.github.com/repos/hearsaycorp/richenum/issues/39"},"comments":{"href":"https://api.github.com/repos/hearsaycorp/richenum/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hearsaycorp/richenum/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/hearsaycorp/richenum/statuses/117c8208bdbf995dcd76b37af8ecbf1e8a4453a3"}}}}