我得到了一个.json响应,并根据数据库值断言它,但是在测试中断言期间,我不断得到一个错误。最好的方法是什么? 我的错误:
db_results = data_base.fetchall()
assert len(db_results) == 1
db_results = db_results[0]
response = response.json
> assert response['dealW2Calculations']['pitiPercentage'] == db_results.PITIPercentage
E AssertionError: assert Decimal('11.762581090909090909090909090') == Decimal('11.76')
E + where Decimal('11.76') = (18966, 20506, 1, Decimal('11.76'), Decimal('11.76'), Decimal('17.217126545454545'), Decimal('403000.0000'), Decimal('...02000.0000'), Decimal('107000.0000'), True, False, None, False, F`enter code here`alse, None, b'\x00\x00\x00\x00\x00\x0f\x8f\xb0', None).PITIPercentage
有两种方法确实假设
a = decimal.Decimal("11.762581090909090909090909090")
和b = decimal.Decimal("11.76")
assert round(a, 2) == round(b, 2)
李>unittest
单元测试中使用,您可以使用^{相关问题 更多 >
编程相关推荐