)]}'
{"cinder/tests/test_pure.py":[{"author":{"_account_id":9535,"name":"Gorka Eguileor","email":"geguileo@redhat.com","username":"Gorka"},"change_message_id":"6658fb8ca34d492a658602a3bae373b83bc24e06","unresolved":false,"context_lines":[{"line_number":28,"context_line":"        return f"},{"line_number":29,"context_line":"    return _decorator"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"patch_retry \u003d mock.patch(\u0027cinder.utils.retry\u0027, fake_retry)"},{"line_number":32,"context_line":"patch_retry.start()"},{"line_number":33,"context_line":"sys.modules[\u0027purestorage\u0027] \u003d mock.Mock()"},{"line_number":34,"context_line":"from cinder.volume.drivers import pure"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_ba34c2fb","line":31,"updated":"2015-03-12 17:23:16.000000000","message":"I think this is a good solution, or at least as good as it gets.\nI recently found myself with the same problem for another patch and I couldn\u0027t find a better way either. :(","commit_id":"3947faca85c221f3373840bf1ab54b20a8fed4c6"},{"author":{"_account_id":4523,"name":"Eric Harney","email":"eharney@redhat.com","username":"eharney"},"change_message_id":"e519a8a5a703ccdacc4b2e4f970ee00abb3c2563","unresolved":false,"context_lines":[{"line_number":28,"context_line":"        return f"},{"line_number":29,"context_line":"    return _decorator"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"patch_retry \u003d mock.patch(\u0027cinder.utils.retry\u0027, fake_retry)"},{"line_number":32,"context_line":"patch_retry.start()"},{"line_number":33,"context_line":"sys.modules[\u0027purestorage\u0027] \u003d mock.Mock()"},{"line_number":34,"context_line":"from cinder.volume.drivers import pure"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_728b8e1e","line":31,"updated":"2015-03-11 16:34:59.000000000","message":"Why can\u0027t this be done in the test case instead of here?  This is still kind of messy.","commit_id":"3947faca85c221f3373840bf1ab54b20a8fed4c6"},{"author":{"_account_id":11600,"name":"Michał Dulko","email":"michal.dulko@gmail.com","username":"dulek"},"change_message_id":"4844fbcbda0ca6f49d1ee074f1a6a8c6b88f0557","unresolved":false,"context_lines":[{"line_number":28,"context_line":"        return f"},{"line_number":29,"context_line":"    return _decorator"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"patch_retry \u003d mock.patch(\u0027cinder.utils.retry\u0027, fake_retry)"},{"line_number":32,"context_line":"patch_retry.start()"},{"line_number":33,"context_line":"sys.modules[\u0027purestorage\u0027] \u003d mock.Mock()"},{"line_number":34,"context_line":"from cinder.volume.drivers import pure"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_7298ee1b","line":31,"in_reply_to":"9a80dd14_728b8e1e","updated":"2015-03-11 16:41:03.000000000","message":"Decorators are applied on import, that\u0027s why this was done like that.","commit_id":"3947faca85c221f3373840bf1ab54b20a8fed4c6"},{"author":{"_account_id":12924,"name":"Patrick East","email":"east.patrick@gmail.com","username":"patrick.east"},"change_message_id":"8da408ab4dbb12d3b522f3b546a91744ae58277b","unresolved":false,"context_lines":[{"line_number":28,"context_line":"        return f"},{"line_number":29,"context_line":"    return _decorator"},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"patch_retry \u003d mock.patch(\u0027cinder.utils.retry\u0027, fake_retry)"},{"line_number":32,"context_line":"patch_retry.start()"},{"line_number":33,"context_line":"sys.modules[\u0027purestorage\u0027] \u003d mock.Mock()"},{"line_number":34,"context_line":"from cinder.volume.drivers import pure"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a80dd14_327cb6b5","line":31,"in_reply_to":"9a80dd14_728b8e1e","updated":"2015-03-11 16:43:16.000000000","message":"The problem is that decorators have to be mocked before any code is imported that uses them. So as soon as you import cinder.volume.drivers.pure the decorator has already wrapped the method and afaik you can\u0027t easily change it.\n\nI spent a bunch of time when initially adding this change in looking for a better way to do this, but mocking it this way seemed to be a \"normal\" way of mocking decorators.\n\nAll that being said I\u0027m still kind of a noob at python, so if there is a way to mock a decorator in a test method after the method has been imported we should definitely go that route.","commit_id":"3947faca85c221f3373840bf1ab54b20a8fed4c6"}]}
