)]}'
{"nova/tests/unit/privsep/test_path.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"841acc317ca173440258d1f174dfb9e46c2c3136","unresolved":false,"context_lines":[{"line_number":48,"context_line":""},{"line_number":49,"context_line":"    @mock.patch(\u0027os.path.exists\u0027, return_value\u003dTrue)"},{"line_number":50,"context_line":"    def test_write(self, mock_exists):"},{"line_number":51,"context_line":"        mock_open \u003d mock.mock_open()"},{"line_number":52,"context_line":"        with mock.patch.object(six.moves.builtins, \u0027open\u0027,"},{"line_number":53,"context_line":"                               new\u003dmock_open) as mock_open:"},{"line_number":54,"context_line":"            nova.privsep.path.writefile(\u0027/fake/path/file\u0027, \u0027w\u0027, \u0027foo\u0027)"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"            handle \u003d mock_open()"},{"line_number":57,"context_line":"            mock_exists.assert_called_with(\u0027/fake/path\u0027)"},{"line_number":58,"context_line":"            self.assertTrue(mock.call(\u0027/fake/path/file\u0027, \u0027w\u0027) in"},{"line_number":59,"context_line":"                            mock_open.mock_calls)"},{"line_number":60,"context_line":"            handle.write.assert_called_with(\u0027foo\u0027)"},{"line_number":61,"context_line":""},{"line_number":62,"context_line":"    @mock.patch(\u0027os.path.exists\u0027, return_value\u003dFalse)"},{"line_number":63,"context_line":"    def test_write_dir_missing(self, mock_exists):"}],"source_content_type":"text/x-python","patch_set":3,"id":"5fc1f717_40e4dc3c","line":60,"range":{"start_line":51,"start_character":8,"end_line":60,"end_character":50},"updated":"2019-04-01 20:00:47.000000000","message":"with three *different* things called mock_open, this test case is tough to follow. It simplifies to:\n\n    @mock.patch(\u0027os.path.exists\u0027, return_value\u003dTrue)\n    def test_write(self, mock_exists):\n        mock_open \u003d mock.mock_open()\n        with mock.patch.object(six.moves.builtins, \u0027open\u0027,\n                               new\u003dmock_open):\n            nova.privsep.path.writefile(\u0027/fake/path/file\u0027, \u0027w\u0027, \u0027foo\u0027)\n\n            mock_exists.assert_called_with(\u0027/fake/path\u0027)\n            self.assertTrue(mock.call(\u0027/fake/path/file\u0027, \u0027w\u0027) in\n                            mock_open.mock_calls)\n        mock_open.return_value.write.assert_called_with(\u0027foo\u0027)\n\n...which, if not crystal clear, is at least somewhat more comprehensible.","commit_id":"3a2ffb73bdfd231a3fdc50964fec72073ced7a06"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"9d0e0ce827007e3de78f017bb945299f16ca40dd","unresolved":false,"context_lines":[{"line_number":48,"context_line":""},{"line_number":49,"context_line":"    @mock.patch(\u0027os.path.exists\u0027, return_value\u003dTrue)"},{"line_number":50,"context_line":"    def test_write(self, mock_exists):"},{"line_number":51,"context_line":"        mock_open \u003d mock.mock_open()"},{"line_number":52,"context_line":"        with mock.patch.object(six.moves.builtins, \u0027open\u0027,"},{"line_number":53,"context_line":"                               new\u003dmock_open) as mock_open:"},{"line_number":54,"context_line":"            nova.privsep.path.writefile(\u0027/fake/path/file\u0027, \u0027w\u0027, \u0027foo\u0027)"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"            handle \u003d mock_open()"},{"line_number":57,"context_line":"            mock_exists.assert_called_with(\u0027/fake/path\u0027)"},{"line_number":58,"context_line":"            self.assertTrue(mock.call(\u0027/fake/path/file\u0027, \u0027w\u0027) in"},{"line_number":59,"context_line":"                            mock_open.mock_calls)"},{"line_number":60,"context_line":"            handle.write.assert_called_with(\u0027foo\u0027)"},{"line_number":61,"context_line":""},{"line_number":62,"context_line":"    @mock.patch(\u0027os.path.exists\u0027, return_value\u003dFalse)"},{"line_number":63,"context_line":"    def test_write_dir_missing(self, mock_exists):"}],"source_content_type":"text/x-python","patch_set":3,"id":"5fc1f717_4f4e0d97","line":60,"range":{"start_line":51,"start_character":8,"end_line":60,"end_character":50},"in_reply_to":"5fc1f717_40e4dc3c","updated":"2019-04-04 08:38:43.000000000","message":"Done","commit_id":"3a2ffb73bdfd231a3fdc50964fec72073ced7a06"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"5de98d34c45551fc18b35e8fc00845526a6d0b90","unresolved":false,"context_lines":[{"line_number":53,"context_line":"                               new\u003dmock_open):"},{"line_number":54,"context_line":"            nova.privsep.path.writefile(\u0027/fake/path/file\u0027, \u0027w\u0027, \u0027foo\u0027)"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"        handle \u003d mock_open()"},{"line_number":57,"context_line":"        mock_exists.assert_called_with(\u0027/fake/path\u0027)"},{"line_number":58,"context_line":"        self.assertTrue(mock.call(\u0027/fake/path/file\u0027, \u0027w\u0027) in"},{"line_number":59,"context_line":"                        mock_open.mock_calls)"}],"source_content_type":"text/x-python","patch_set":7,"id":"5fc1f717_ab3993f2","line":56,"range":{"start_line":56,"start_character":8,"end_line":56,"end_character":28},"updated":"2019-04-04 21:34:35.000000000","message":"What bugs me about this is it at least appears to represent a second invocation of the open mock. I\u0027m guessing mock.mock_open has some kind of singleton behavior so that the return_value is the same no matter how many times you call it - but I suspect that\u0027s by luck rather than by design.\n\nSo it would be cleaner to get rid of \u0027handle\u0027 and change L60 to\n\n mock_open.return_value.write.assert...","commit_id":"074d3867bc4c074bdd8356e17424d2eb391ecf30"},{"author":{"_account_id":2271,"name":"Michael Still","email":"mikal@stillhq.com","username":"mikalstill"},"change_message_id":"5053fd0ae09d8165b3ff7c3c6fe971ff5be8d4de","unresolved":false,"context_lines":[{"line_number":53,"context_line":"                               new\u003dmock_open):"},{"line_number":54,"context_line":"            nova.privsep.path.writefile(\u0027/fake/path/file\u0027, \u0027w\u0027, \u0027foo\u0027)"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"        handle \u003d mock_open()"},{"line_number":57,"context_line":"        mock_exists.assert_called_with(\u0027/fake/path\u0027)"},{"line_number":58,"context_line":"        self.assertTrue(mock.call(\u0027/fake/path/file\u0027, \u0027w\u0027) in"},{"line_number":59,"context_line":"                        mock_open.mock_calls)"}],"source_content_type":"text/x-python","patch_set":7,"id":"5fc1f717_5493eb5c","line":56,"range":{"start_line":56,"start_character":8,"end_line":56,"end_character":28},"in_reply_to":"5fc1f717_ab3993f2","updated":"2019-04-05 09:37:20.000000000","message":"The handle thing is pretty much straight from the mock docs -- https://docs.python.org/3/library/unittest.mock.html#mock-open\n\nI can rearrange things, but I wont get to it for a day or two because I am about to go offline to run a bushwalking course. If this is still unmerged when I get back I\u0027ll do something about it.","commit_id":"074d3867bc4c074bdd8356e17424d2eb391ecf30"}]}
