{"action":"created","comment":{"url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/comments/87155221","pull_request_review_id":7777777,"id":87155221,"diff_hunk":"@@ -15,20 +16,28 @@\n # to do it.\n \n \n-def test_mail(mailoutbox):\n-    assert mailoutbox is mail.outbox  # check that mail.outbox and fixture value is same object\n-    assert len(mailoutbox) == 0\n+def test_direct_mailbox_access_not_allowed():\n+    with pytest.raises(AssertionError):\n+        len(mail.outbox)\n+\n+    with pytest.raises(AssertionError):\n+        mail.outbox[0]\n+\n+    with pytest.raises(AssertionError):\n+        if mail.outbox:\n+            pass\n+\n+\n+def test_direct_mailbox_proection_should_not_break_sending_mail():\n     mail.send_mail('subject', 'body', 'from@example.com', ['to@example.com'])\n-    assert len(mailoutbox) == 1\n-    m = mailoutbox[0]\n-    assert m.subject == 'subject'\n-    assert m.body == 'body'\n-    assert m.from_email == 'from@example.com'\n-    assert list(m.to) == ['to@example.com']\n \n \n-def test_mail_again(mailoutbox):\n-    test_mail(mailoutbox)\n+class TestDirectAccessWorksForDjangoTestCase(TestCase):\n+\n+    def test_one(self):\n+        assert len(mail.outbox) == 0\n+        mail.send_mail('subject', 'body', 'from@example.com', ['to@example.com'])\n+        assert len(mail.outbox) == 1","path":"tests/test_environment.py","position":43,"original_position":44,"commit_id":"fa67ab0c09dc46993d70f7e3324f8b38e2f7ebc9","original_commit_id":"fa67ab0c09dc46993d70f7e3324f8b38e2f7ebc9","user":{"login":"pelme","id":20529,"avatar_url":"https://avatars.githubusercontent.com/u/20529?v=3","gravatar_id":"","url":"https://api.github.com/users/pelme","html_url":"https://github.com/pelme","followers_url":"https://api.github.com/users/pelme/followers","following_url":"https://api.github.com/users/pelme/following{/other_user}","gists_url":"https://api.github.com/users/pelme/gists{/gist_id}","starred_url":"https://api.github.com/users/pelme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pelme/subscriptions","organizations_url":"https://api.github.com/users/pelme/orgs","repos_url":"https://api.github.com/users/pelme/repos","events_url":"https://api.github.com/users/pelme/events{/privacy}","received_events_url":"https://api.github.com/users/pelme/received_events","type":"User","site_admin":false},"body":"Please add test_two that does the same thing and checks to make sure the clearing works :)","created_at":"2016-11-09T09:17:30Z","updated_at":"2016-11-09T09:17:30Z","html_url":"https://github.com/pytest-dev/pytest-django/pull/410#discussion_r87155221","pull_request_url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410","_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/comments/87155221"},"html":{"href":"https://github.com/pytest-dev/pytest-django/pull/410#discussion_r87155221"},"pull_request":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410"}}},"pull_request":{"url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410","id":91044699,"html_url":"https://github.com/pytest-dev/pytest-django/pull/410","diff_url":"https://github.com/pytest-dev/pytest-django/pull/410.diff","patch_url":"https://github.com/pytest-dev/pytest-django/pull/410.patch","issue_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/410","number":410,"state":"open","locked":false,"title":"Adding mailoutbox fixture, and removing internal _django_clear_outbox","user":{"login":"peterlauri","id":3514945,"avatar_url":"https://avatars.githubusercontent.com/u/3514945?v=3","gravatar_id":"","url":"https://api.github.com/users/peterlauri","html_url":"https://github.com/peterlauri","followers_url":"https://api.github.com/users/peterlauri/followers","following_url":"https://api.github.com/users/peterlauri/following{/other_user}","gists_url":"https://api.github.com/users/peterlauri/gists{/gist_id}","starred_url":"https://api.github.com/users/peterlauri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterlauri/subscriptions","organizations_url":"https://api.github.com/users/peterlauri/orgs","repos_url":"https://api.github.com/users/peterlauri/repos","events_url":"https://api.github.com/users/peterlauri/events{/privacy}","received_events_url":"https://api.github.com/users/peterlauri/received_events","type":"User","site_admin":false},"body":"pytest-django doesn't provide any mechanism to get the mail outbox, however it is clearing the mailbox, that effects external fixtures that might want to interact with the mail.outbox. This fixture stores previous outbox (if any), creates a new list for usage in fixture, and then restores the state to what it was previously...\n\nThis PR is initiated to add a mailoutbox fixture, and if interested of getting this released, I would enhance it with documentation and possible tests...\n\nPR #407 would not be needed if this is chosen as the path to go...\n","created_at":"2016-10-26T16:52:27Z","updated_at":"2016-11-09T09:17:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d0713f1eb65cb178b4b4dc0b98134c7d6c4736a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410/commits","review_comments_url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410/comments","review_comment_url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/410/comments","statuses_url":"https://api.github.com/repos/pytest-dev/pytest-django/statuses/fa67ab0c09dc46993d70f7e3324f8b38e2f7ebc9","head":{"label":"dolphinkiss:add_mailbox_fixture","ref":"add_mailbox_fixture","sha":"fa67ab0c09dc46993d70f7e3324f8b38e2f7ebc9","user":{"login":"dolphinkiss","id":7247123,"avatar_url":"https://avatars.githubusercontent.com/u/7247123?v=3","gravatar_id":"","url":"https://api.github.com/users/dolphinkiss","html_url":"https://github.com/dolphinkiss","followers_url":"https://api.github.com/users/dolphinkiss/followers","following_url":"https://api.github.com/users/dolphinkiss/following{/other_user}","gists_url":"https://api.github.com/users/dolphinkiss/gists{/gist_id}","starred_url":"https://api.github.com/users/dolphinkiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolphinkiss/subscriptions","organizations_url":"https://api.github.com/users/dolphinkiss/orgs","repos_url":"https://api.github.com/users/dolphinkiss/repos","events_url":"https://api.github.com/users/dolphinkiss/events{/privacy}","received_events_url":"https://api.github.com/users/dolphinkiss/received_events","type":"Organization","site_admin":false},"repo":{"id":55231798,"name":"pytest-django","full_name":"dolphinkiss/pytest-django","owner":{"login":"dolphinkiss","id":7247123,"avatar_url":"https://avatars.githubusercontent.com/u/7247123?v=3","gravatar_id":"","url":"https://api.github.com/users/dolphinkiss","html_url":"https://github.com/dolphinkiss","followers_url":"https://api.github.com/users/dolphinkiss/followers","following_url":"https://api.github.com/users/dolphinkiss/following{/other_user}","gists_url":"https://api.github.com/users/dolphinkiss/gists{/gist_id}","starred_url":"https://api.github.com/users/dolphinkiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolphinkiss/subscriptions","organizations_url":"https://api.github.com/users/dolphinkiss/orgs","repos_url":"https://api.github.com/users/dolphinkiss/repos","events_url":"https://api.github.com/users/dolphinkiss/events{/privacy}","received_events_url":"https://api.github.com/users/dolphinkiss/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dolphinkiss/pytest-django","description":"A Django plugin for pytest.","fork":true,"url":"https://api.github.com/repos/dolphinkiss/pytest-django","forks_url":"https://api.github.com/repos/dolphinkiss/pytest-django/forks","keys_url":"https://api.github.com/repos/dolphinkiss/pytest-django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dolphinkiss/pytest-django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dolphinkiss/pytest-django/teams","hooks_url":"https://api.github.com/repos/dolphinkiss/pytest-django/hooks","issue_events_url":"https://api.github.com/repos/dolphinkiss/pytest-django/issues/events{/number}","events_url":"https://api.github.com/repos/dolphinkiss/pytest-django/events","assignees_url":"https://api.github.com/repos/dolphinkiss/pytest-django/assignees{/user}","branches_url":"https://api.github.com/repos/dolphinkiss/pytest-django/branches{/branch}","tags_url":"https://api.github.com/repos/dolphinkiss/pytest-django/tags","blobs_url":"https://api.github.com/repos/dolphinkiss/pytest-django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dolphinkiss/pytest-django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dolphinkiss/pytest-django/git/refs{/sha}","trees_url":"https://api.github.com/repos/dolphinkiss/pytest-django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dolphinkiss/pytest-django/statuses/{sha}","languages_url":"https://api.github.com/repos/dolphinkiss/pytest-django/languages","stargazers_url":"https://api.github.com/repos/dolphinkiss/pytest-django/stargazers","contributors_url":"https://api.github.com/repos/dolphinkiss/pytest-django/contributors","subscribers_url":"https://api.github.com/repos/dolphinkiss/pytest-django/subscribers","subscription_url":"https://api.github.com/repos/dolphinkiss/pytest-django/subscription","commits_url":"https://api.github.com/repos/dolphinkiss/pytest-django/commits{/sha}","git_commits_url":"https://api.github.com/repos/dolphinkiss/pytest-django/git/commits{/sha}","comments_url":"https://api.github.com/repos/dolphinkiss/pytest-django/comments{/number}","issue_comment_url":"https://api.github.com/repos/dolphinkiss/pytest-django/issues/comments{/number}","contents_url":"https://api.github.com/repos/dolphinkiss/pytest-django/contents/{+path}","compare_url":"https://api.github.com/repos/dolphinkiss/pytest-django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dolphinkiss/pytest-django/merges","archive_url":"https://api.github.com/repos/dolphinkiss/pytest-django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dolphinkiss/pytest-django/downloads","issues_url":"https://api.github.com/repos/dolphinkiss/pytest-django/issues{/number}","pulls_url":"https://api.github.com/repos/dolphinkiss/pytest-django/pulls{/number}","milestones_url":"https://api.github.com/repos/dolphinkiss/pytest-django/milestones{/number}","notifications_url":"https://api.github.com/repos/dolphinkiss/pytest-django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dolphinkiss/pytest-django/labels{/name}","releases_url":"https://api.github.com/repos/dolphinkiss/pytest-django/releases{/id}","deployments_url":"https://api.github.com/repos/dolphinkiss/pytest-django/deployments","created_at":"2016-04-01T12:46:04Z","updated_at":"2016-04-01T12:46:06Z","pushed_at":"2016-11-09T09:14:38Z","git_url":"git://github.com/dolphinkiss/pytest-django.git","ssh_url":"git@github.com:dolphinkiss/pytest-django.git","clone_url":"https://github.com/dolphinkiss/pytest-django.git","svn_url":"https://github.com/dolphinkiss/pytest-django","homepage":"","size":989,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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:master","ref":"master","sha":"54650ea556af0eda5dd5b95f727ccef603c7da47","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":2484397,"name":"pytest-django","full_name":"pytest-dev/pytest-django","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-django","description":"A Django plugin for pytest.","fork":false,"url":"https://api.github.com/repos/pytest-dev/pytest-django","forks_url":"https://api.github.com/repos/pytest-dev/pytest-django/forks","keys_url":"https://api.github.com/repos/pytest-dev/pytest-django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pytest-dev/pytest-django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pytest-dev/pytest-django/teams","hooks_url":"https://api.github.com/repos/pytest-dev/pytest-django/hooks","issue_events_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/events{/number}","events_url":"https://api.github.com/repos/pytest-dev/pytest-django/events","assignees_url":"https://api.github.com/repos/pytest-dev/pytest-django/assignees{/user}","branches_url":"https://api.github.com/repos/pytest-dev/pytest-django/branches{/branch}","tags_url":"https://api.github.com/repos/pytest-dev/pytest-django/tags","blobs_url":"https://api.github.com/repos/pytest-dev/pytest-django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pytest-dev/pytest-django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pytest-dev/pytest-django/git/refs{/sha}","trees_url":"https://api.github.com/repos/pytest-dev/pytest-django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pytest-dev/pytest-django/statuses/{sha}","languages_url":"https://api.github.com/repos/pytest-dev/pytest-django/languages","stargazers_url":"https://api.github.com/repos/pytest-dev/pytest-django/stargazers","contributors_url":"https://api.github.com/repos/pytest-dev/pytest-django/contributors","subscribers_url":"https://api.github.com/repos/pytest-dev/pytest-django/subscribers","subscription_url":"https://api.github.com/repos/pytest-dev/pytest-django/subscription","commits_url":"https://api.github.com/repos/pytest-dev/pytest-django/commits{/sha}","git_commits_url":"https://api.github.com/repos/pytest-dev/pytest-django/git/commits{/sha}","comments_url":"https://api.github.com/repos/pytest-dev/pytest-django/comments{/number}","issue_comment_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/comments{/number}","contents_url":"https://api.github.com/repos/pytest-dev/pytest-django/contents/{+path}","compare_url":"https://api.github.com/repos/pytest-dev/pytest-django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pytest-dev/pytest-django/merges","archive_url":"https://api.github.com/repos/pytest-dev/pytest-django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pytest-dev/pytest-django/downloads","issues_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues{/number}","pulls_url":"https://api.github.com/repos/pytest-dev/pytest-django/pulls{/number}","milestones_url":"https://api.github.com/repos/pytest-dev/pytest-django/milestones{/number}","notifications_url":"https://api.github.com/repos/pytest-dev/pytest-django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pytest-dev/pytest-django/labels{/name}","releases_url":"https://api.github.com/repos/pytest-dev/pytest-django/releases{/id}","deployments_url":"https://api.github.com/repos/pytest-dev/pytest-django/deployments","created_at":"2011-09-29T19:35:55Z","updated_at":"2016-11-07T15:01:51Z","pushed_at":"2016-11-09T09:14:39Z","git_url":"git://github.com/pytest-dev/pytest-django.git","ssh_url":"git@github.com:pytest-dev/pytest-django.git","clone_url":"https://github.com/pytest-dev/pytest-django.git","svn_url":"https://github.com/pytest-dev/pytest-django","homepage":"https://pytest-django.readthedocs.io/","size":1355,"stargazers_count":264,"watchers_count":264,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":83,"forks":132,"open_issues":83,"watchers":264,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410"},"html":{"href":"https://github.com/pytest-dev/pytest-django/pull/410"},"issue":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/issues/410"},"comments":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/issues/410/comments"},"review_comments":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410/comments"},"review_comment":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/pulls/410/commits"},"statuses":{"href":"https://api.github.com/repos/pytest-dev/pytest-django/statuses/fa67ab0c09dc46993d70f7e3324f8b38e2f7ebc9"}}}}
{"actor":{"display_login":"pelme"}}