我想解决这个错误并完成测试:
管理员.py
def suit_row_attributes(self, obj, request):
"""Add colours to the rows according to the status"""
type_error = 'notSent'
status_colours = {Transaction.STATUS_REJECTED: 'error', Transaction.STATUS_RECEIVED: 'received',
Transaction.STATUS_PENDING: 'warning', Transaction.STATUS_ACCEPTED: 'success',
type_error: 'notSent'}
try:
tt_status = Transaction.objects.get(txid=obj.numero).last_status
except Transaction.DoesNotExist:
tt_status = type_error
return {'class': status_colours.get(tt_status, 'success')}
在测试.py
def test_suit_row_attributes(self):
self.assertEqual(self.admin_instance.suit_row_attributes(self.errortr_obj), {'class': 'notSent'})
有人能帮助我吗?