问题描述
如果我像这样使用 mailoutbox 固定装置,它会起作用:
def test_send_invoices_via_mail_page(user_client,invoice,mailoutbox):
url = reverse(send_invoices_via_mail_page)
response = user_client.get(url)
assert response.status_code == 200
log = LogOfInvoiceMail.objects.get(invoice=invoice)
assert log.success,log.exception
assert log.invoice == invoice
assert log.exception == ''
assert len(mailoutbox) == 1,mailoutbox
但是如果我这样使用它就会失败:
def test_send_invoices_via_mail_page(mailoutbox,user_client,invoice):
错误:
> assert len(mailoutbox) == 1,mailoutbox
E AssertionError: []
E assert 0 == 1
为什么参数的顺序在这里很重要?
我 100% 确定 mail.send_mail()
在这两种情况下都会被调用,因为我对其进行了十次测试(用十种不同的方式)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)