浏览代码

Update testing.rst (#4046)

Without mocking the retry method of the task and actually setting Retry as side effect, raising an operational error within the task will not lead to a Retry exception but the original Exception to be thrown as the task is called directly.
Rico Moorman 7 年之前
父节点
当前提交
e37588fa66
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      docs/userguide/testing.rst

+ 3 - 2
docs/userguide/testing.rst

@@ -76,8 +76,9 @@ in this example:
                 name='Foo',
             )
 
-            # set a side effect on the patched method
-            # so that it raises the error we want.
+            # Set a side effect on the patched methods
+            # so that they raise the errors we want.
+            send_order_retry.side_effect = Retry()
             product_order.side_effect = OperationalError()
 
             with raises(Retry):