我是unittest新手,我想知道是否有任何方法可以将unittest断言函数中的方法作为参数传递。我想看看API调用是否返回包含单词“code”的JSON对象。如果“code”不在我希望它断言的对象中
我得到以下错误
TypeError: argument of type 'NoneType' is not iterable
因为unittest函数将方法视为非类型值
import unittest
class Testing(unittest.TestCase):
def test_createDepositAddress(self):
result = client.createDepositAddress({"currencySymbol":"BTC"})
self.assertIn("code", result)
如何检查调用client.createDepositAddress({“currencySymbol”:“BTC”})返回的JSON对象中是否有“code”
下面是从调用client.createDepositAddress({“currencySymbol”:“BTC”})返回的JSON负载
{
"code": "CRYPTO_ADDRESS_ALREADY_EXISTS"
}
目前没有回答
相关问题 更多 >
编程相关推荐