【发布时间】:2016-06-07 10:42:52
【问题描述】:
我正在为使用 Stripe 支付的模块编写测试。而且我想对其进行模拟,以使其不向 API 发送查询。 我使用下一个代码,但我仍然对 API 有查询。我不明白为什么?每次我运行测试时,此类查询都会出现在 Stripe 日志中:
/v1/customers/cus_*********/subscription
这是我的代码:
@patch('stripe.Subscription.save')
def test_subscription(self, subscription_update):
subscription_update.return_value = self.convert_to_stripe_object({...})
# there is test code
这是什么原因,我该如何修补该查询?感谢您的帮助!
【问题讨论】:
-
` @patch('stripe.Plan.list') @patch('stripe.Customer.save') @patch('stripe.Customer.create') @patch('stripe.Token. create') @patch('stripe.Customer.delete') @patch('stripe.Plan.create') @patch('stripe.Plan.delete') `我使用上述所有方法进行修补,它可以正常工作在文档中描述。这很奇怪,但我在这里找不到需要的选项:stripe.com/docs/api/python#subscriptions
标签: python testing mocking patch