{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/comments/54029615","id":54029615,"diff_hunk":"@@ -12,138 +12,115 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n-import unittest\n-\n import bookshelf\n import config\n from flaky import flaky\n from gcloud.exceptions import ServiceUnavailable\n-from nose.plugins.attrib import attr\n+import py.test\n \n \n def flaky_filter(e, *args):\n     return isinstance(e, ServiceUnavailable)\n \n \n-@flaky(rerun_filter=flaky_filter)\n-class IntegrationBase(unittest.TestCase):\n-\n-    def createBooks(self, n=1):\n-        with self.app.test_request_context():\n-            for i in range(1, n + 1):\n-                self.model.create({'title': u'Book {0}'.format(i)})\n-\n-    def setUp(self):\n-        self.app = bookshelf.create_app(\n-            config,\n-            testing=True,\n-            config_overrides={\n-                'DATA_BACKEND': self.backend\n-            }\n-        )\n-\n-        with self.app.app_context():\n-            self.model = bookshelf.get_model()\n-\n-        self.ids_to_delete = []\n-\n-        # Monkey-patch create so we can track the IDs of every item\n-        # created and delete them during tearDown.\n-        self.original_create = self.model.create\n+@py.test.yield_fixture(params=['datastore', 'cloudsql', 'mongodb'])\n+def app(request, monkeypatch):\n+    app = bookshelf.create_app(\n+        config,\n+        testing=True,\n+        config_overrides={\n+            'DATA_BACKEND': request.param\n+        })\n \n-        def tracking_create(*args, **kwargs):\n-            res = self.original_create(*args, **kwargs)\n-            self.ids_to_delete.append(res['id'])\n-            return res\n+    with app.test_request_context():\n+        yield app\n \n-        self.model.create = tracking_create\n \n-    def tearDown(self):\n+@py.test.yield_fixture\n+def model(monkeypatch, app):\n+    model = bookshelf.get_model()\n \n-        # Delete all items that we created during tests.\n-        with self.app.test_request_context():\n-            list(map(self.model.delete, self.ids_to_delete))\n+    ids_to_delete = []\n \n-        self.model.create = self.original_create\n+    # Monkey-patch create so we can track the IDs of every item\n+    # created and delete them during tearDown.\n+    original_create = model.create\n \n+    def tracking_create(*args, **kwargs):\n+        res = original_create(*args, **kwargs)\n+        ids_to_delete.append(res['id'])\n+        return res\n \n-@attr('slow')\n-class CrudTestsMixin(object):\n-    def testList(self):\n-        self.createBooks(11)\n+    monkeypatch.setattr(model, 'create', tracking_create)\n \n-        with self.app.test_client() as c:\n-            rv = c.get('/books/')\n+    yield model\n \n-        assert rv.status == '200 OK'\n+    # Delete all items that we created during tests.\n+    list(map(model.delete, ids_to_delete))","path":"2-structured-data/tests/test_crud.py","position":93,"original_position":93,"commit_id":"562ab5ff5714edc46de52c9ff35ac4ee527cdf2e","original_commit_id":"562ab5ff5714edc46de52c9ff35ac4ee527cdf2e","user":{"login":"jerjou","id":913439,"avatar_url":"https://avatars.githubusercontent.com/u/913439?v=3","gravatar_id":"","url":"https://api.github.com/users/jerjou","html_url":"https://github.com/jerjou","followers_url":"https://api.github.com/users/jerjou/followers","following_url":"https://api.github.com/users/jerjou/following{/other_user}","gists_url":"https://api.github.com/users/jerjou/gists{/gist_id}","starred_url":"https://api.github.com/users/jerjou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerjou/subscriptions","organizations_url":"https://api.github.com/users/jerjou/orgs","repos_url":"https://api.github.com/users/jerjou/repos","events_url":"https://api.github.com/users/jerjou/events{/privacy}","received_events_url":"https://api.github.com/users/jerjou/received_events","type":"User","site_admin":false},"body":"Yeeeeeaaaaah.... I should migrate my brain from python 2 to 3 one of these days...","created_at":"2016-02-25T00:05:51Z","updated_at":"2016-02-25T00:05:51Z","html_url":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25#discussion_r54029615","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/comments/54029615"},"html":{"href":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25#discussion_r54029615"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25","id":60596379,"html_url":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25","diff_url":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25.diff","patch_url":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/25","number":25,"state":"open","locked":false,"title":"Refactoring 2-structured-data tests to use py.test","user":{"login":"jonparrott","id":250995,"avatar_url":"https://avatars.githubusercontent.com/u/250995?v=3","gravatar_id":"","url":"https://api.github.com/users/jonparrott","html_url":"https://github.com/jonparrott","followers_url":"https://api.github.com/users/jonparrott/followers","following_url":"https://api.github.com/users/jonparrott/following{/other_user}","gists_url":"https://api.github.com/users/jonparrott/gists{/gist_id}","starred_url":"https://api.github.com/users/jonparrott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonparrott/subscriptions","organizations_url":"https://api.github.com/users/jonparrott/orgs","repos_url":"https://api.github.com/users/jonparrott/repos","events_url":"https://api.github.com/users/jonparrott/events{/privacy}","received_events_url":"https://api.github.com/users/jonparrott/received_events","type":"User","site_admin":false},"body":"@waprin Note that this is being merged into the `pytest-refactor` branch, which we'll merge into master when all is done.\r\n\r\nAlso, question for you: I can put all of the test functions in a class and mark the whole class as flaky. That'll keep me from having to mark each test case as flaky. Your call.","created_at":"2016-02-24T23:14:25Z","updated_at":"2016-02-25T00:05:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b60cc09793d35cca3be9c34120eafbda79be9303","assignee":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/25/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/statuses/562ab5ff5714edc46de52c9ff35ac4ee527cdf2e","head":{"label":"GoogleCloudPlatform:pytest-refactor-step-2","ref":"pytest-refactor-step-2","sha":"562ab5ff5714edc46de52c9ff35ac4ee527cdf2e","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":40326118,"name":"getting-started-python","full_name":"GoogleCloudPlatform/getting-started-python","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/getting-started-python","description":"Code samples for using Python on Google Cloud Platform","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/deployments","created_at":"2015-08-06T20:45:12Z","updated_at":"2016-02-22T21:02:53Z","pushed_at":"2016-02-24T23:15:08Z","git_url":"git://github.com/GoogleCloudPlatform/getting-started-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/getting-started-python.git","clone_url":"https://github.com/GoogleCloudPlatform/getting-started-python.git","svn_url":"https://github.com/GoogleCloudPlatform/getting-started-python","homepage":"https://cloud.google.com/python","size":140,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":13,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:pytest-refactor","ref":"pytest-refactor","sha":"852eedc9643d3f959a12239ff94160e1f9449994","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":40326118,"name":"getting-started-python","full_name":"GoogleCloudPlatform/getting-started-python","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/getting-started-python","description":"Code samples for using Python on Google Cloud Platform","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/deployments","created_at":"2015-08-06T20:45:12Z","updated_at":"2016-02-22T21:02:53Z","pushed_at":"2016-02-24T23:15:08Z","git_url":"git://github.com/GoogleCloudPlatform/getting-started-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/getting-started-python.git","clone_url":"https://github.com/GoogleCloudPlatform/getting-started-python.git","svn_url":"https://github.com/GoogleCloudPlatform/getting-started-python","homepage":"https://cloud.google.com/python","size":140,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":3,"forks":4,"open_issues":3,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25"},"html":{"href":"https://github.com/GoogleCloudPlatform/getting-started-python/pull/25"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/25"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/getting-started-python/statuses/562ab5ff5714edc46de52c9ff35ac4ee527cdf2e"}}}}