)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b1348d87d263c27ac591ba05873b2f43ca7cfef3","unresolved":false,"context_lines":[{"line_number":14,"context_line":"tests to fail."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"To guard against this, we use the SpawnIsSynchronousFixture in"},{"line_number":17,"context_line":"the base class of two known test classes [1][2] that show a"},{"line_number":18,"context_line":"stacktace with _allocate_network_async in successful runs. As a"},{"line_number":19,"context_line":"result, one of the tests has to be fixed due to improper stubbing."},{"line_number":20,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"5faad753_ce8f13cb","line":17,"updated":"2019-09-13 19:10:12.000000000","message":"I originally put this in ProviderUsageBaseTestCase but that seemed a tad bit excessive, but if people want I can move it there.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b3039a7254acd225bce73bf9a49182fc8b68e912","unresolved":false,"context_lines":[{"line_number":15,"context_line":""},{"line_number":16,"context_line":"To guard against this, we use the SpawnIsSynchronousFixture in"},{"line_number":17,"context_line":"the base class of two known test classes [1][2] that show a"},{"line_number":18,"context_line":"stacktace with _allocate_network_async in successful runs. As a"},{"line_number":19,"context_line":"result, one of the tests has to be fixed due to improper stubbing."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"[1] UnsupportedPortResourceRequestBasedSchedulingTest"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"5faad753_654ddd98","line":18,"range":{"start_line":18,"start_character":0,"end_line":18,"end_character":9},"updated":"2019-09-13 21:18:36.000000000","message":"stack trace","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"}],"nova/tests/functional/test_servers.py":[{"author":{"_account_id":8864,"name":"Artom Lifshitz","email":"notartom@gmail.com","username":"artom"},"change_message_id":"f587eb6b9103bc87d243d67f673000e8fe3ce37b","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_c244c749","line":6817,"updated":"2019-09-13 19:23:34.000000000","message":"Could we not do something less clever, like\n\n  side_effect \u003d itertools.chain([original_fill],\n                                itertools.repeat(raise))\n\n?","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"1372086deae2dbf20392f04ef6258198c3f93fcd","unresolved":false,"context_lines":[{"line_number":6806,"context_line":"        # fill is called again, and we simulate that call raises."},{"line_number":6807,"context_line":"        original_fill \u003d nova.scheduler.utils.fill_provider_mapping"},{"line_number":6808,"context_line":""},{"line_number":6809,"context_line":"        def stub_fill_provider_mapping(*args, **kwargs):"},{"line_number":6810,"context_line":"            if not mock_fill.called:"},{"line_number":6811,"context_line":"                return original_fill(*args, **kwargs)"},{"line_number":6812,"context_line":"            raise exception.ResourceProviderTraitRetrievalFailed("},{"line_number":6813,"context_line":"                uuid\u003duuids.rp1)"},{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_8266cfc0","line":6817,"range":{"start_line":6809,"start_character":2,"end_line":6817,"end_character":69},"updated":"2019-09-13 19:34:14.000000000","message":"i know its the same bug can we do\n\n     with mock.patch(\n                \u0027nova.scheduler.utils.fill_provider_mapping\u0027) as mock_fill:\n\n            def stub_fill_provider_mapping(*args, **kwargs):\n                if not mock_fill.called:\n                    return original_fill(*args, **kwargs)\n                raise exception.ResourceProviderTraitRetrievalFailed(\n                    uuid\u003duuids.rp1)\n            mock_fill.side_effect \u003d stub_fill_provider_mapping\n            \n\ninstead","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"068c01fa4226e3d185351a3336866949fd2d5570","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"3fa7e38b_de71a579","line":6817,"in_reply_to":"3fa7e38b_8a476fbd","updated":"2019-10-01 14:57:44.000000000","message":"I have a solution proposal for to avoid (or actually hide) the scope trick. Opinions are welcome https://review.opendev.org/#/c/685950/1/nova/tests/functional/test_servers.py","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"f27ca460170151981e0ff21f79ebfac9786f5962","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_587768a1","line":6817,"in_reply_to":"5faad753_181fb05b","updated":"2019-09-13 21:31:30.000000000","message":"\u003e I won\u0027t push it, but I still don\u0027t like it, if something better can be found.\n\nSame thing my wife said when I proposed.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"09d1e6e26455a6af8cd630aad37538a698ee6450","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_f8109450","line":6817,"in_reply_to":"5faad753_253845ec","updated":"2019-09-13 21:26:42.000000000","message":"At least add a comment to what you\u0027ve got explaining what it\u0027s doing and why it\u0027s necessary to do it this way.\n\nBTW, Matt\u0027s correct that Artom\u0027s suggestion won\u0027t work because the iterable version of side_effect returns the next value (or raises the exception), it doesn\u0027t run it as a method.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":8864,"name":"Artom Lifshitz","email":"notartom@gmail.com","username":"artom"},"change_message_id":"0ad5a1f5685e480d9d92b2ee452025c4b7cf3299","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_181fb05b","line":6817,"in_reply_to":"5faad753_2543656e","updated":"2019-09-13 21:29:12.000000000","message":"I guess side effect is at least a documented part of the mock library [1] (tough you\u0027re saying it might not even work like I think it does), whereas the scope quirk is obscure? Anyways, I won\u0027t push it, but I still don\u0027t like it, if something better can be found.\n\n[1] https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.side_effect","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":8864,"name":"Artom Lifshitz","email":"notartom@gmail.com","username":"artom"},"change_message_id":"2bd346f40d883ba8c55392f619ffe8f6d63ca552","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_a22bcb92","line":6817,"in_reply_to":"5faad753_422a172c","updated":"2019-09-13 20:18:56.000000000","message":"It was intended to be pseudocody and not copy-pastable directly :)","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":8864,"name":"Artom Lifshitz","email":"notartom@gmail.com","username":"artom"},"change_message_id":"f1ef604b93a0f619a69a7a8d0766d7c05cfb50d3","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_b8b21c48","line":6817,"in_reply_to":"5faad753_587768a1","updated":"2019-09-13 21:33:54.000000000","message":"\u003e  \u003e I won\u0027t push it, but I still don\u0027t like it, if something better can be found.\n \u003e \n \u003e Same thing my wife said when I proposed.\n\nthat gets a pity +1 from me","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b3039a7254acd225bce73bf9a49182fc8b68e912","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_e560ed03","line":6817,"in_reply_to":"5faad753_a22bcb92","updated":"2019-09-13 21:18:36.000000000","message":"or\n\n def raise_after_first(*a, **k):\n     # Make subsequent calls raise\n     mock_fill.side_effect \u003d exception.R...\n     return original_fill(*a, **k)\n mock_fill.side_effect \u003d raise_after_first","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"ea752cfe15ff31188f7d8830ecf3bfadfcef5ab5","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"3fa7e38b_8a476fbd","line":6817,"in_reply_to":"5faad753_b8b21c48","updated":"2019-09-16 16:05:07.000000000","message":"@Matt: thanks for finding and fixing my mistake. \n\nI think there is no nice solution here. If we don\u0027t want to dig into the args and kwargs of the stub_fill_provider_mapping to decide what to do then we need to use the outer scope to \u0027remember\u0027 how many times we were called.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"30183d02e279129bb9c6cefa3b765e15e4fdcd85","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_2543656e","line":6817,"in_reply_to":"5faad753_c244c749","updated":"2019-09-13 21:18:19.000000000","message":"\u003e Could we not do something less clever, like\n \u003e \n \u003e side_effect \u003d itertools.chain([original_fill],\n \u003e itertools.repeat(raise))\n \u003e \n \u003e ?\n\nThat seems just as clever to me. Also note that\u0027s basically what the code was doing before I think which wasn\u0027t working properly. I think side_effect as an iterable is return values or exceptions, whatever, but not a replacement function.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":11604,"name":"sean mooney","email":"smooney@redhat.com","username":"sean-k-mooney"},"change_message_id":"56049863f2015c53b0647860673f016ef7a09f85","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_422a172c","line":6817,"in_reply_to":"5faad753_c244c749","updated":"2019-09-13 19:37:44.000000000","message":"itertools.repeat(raise)\nis not vaild python","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"27e099b14a8c3bf5ccd3a3e5363f11aa84341c3d","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_253845ec","line":6817,"in_reply_to":"5faad753_e560ed03","updated":"2019-09-13 21:19:47.000000000","message":"\u003e or\n \u003e \n \u003e def raise_after_first(*a, **k):\n \u003e # Make subsequent calls raise\n \u003e mock_fill.side_effect \u003d exception.R...\n \u003e return original_fill(*a, **k)\n \u003e mock_fill.side_effect \u003d raise_after_first\n\nAlso super clever.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"69e1e6ffcc72e413a4c6d83f9221d37c2a81aeb4","unresolved":false,"context_lines":[{"line_number":6814,"context_line":""},{"line_number":6815,"context_line":"        with mock.patch("},{"line_number":6816,"context_line":"                \u0027nova.scheduler.utils.fill_provider_mapping\u0027,"},{"line_number":6817,"context_line":"                side_effect\u003dstub_fill_provider_mapping) as mock_fill:"},{"line_number":6818,"context_line":"            server \u003d self._create_server("},{"line_number":6819,"context_line":"                flavor\u003dself.flavor,"},{"line_number":6820,"context_line":"                networks\u003d[{\u0027port\u0027: port[\u0027id\u0027]}])"}],"source_content_type":"text/x-python","patch_set":1,"id":"5faad753_f83974d6","line":6817,"in_reply_to":"5faad753_f8109450","updated":"2019-09-13 21:28:15.000000000","message":"Duh, the comment on L6804 is fine.","commit_id":"bb2b7cad294bebd6b3bdd6d10043c3c2fb038140"}]}
