在我的pytest(python 3.7.4)中,我具有测试方法,该方法定义并设置namedtuple
的值。但是,尽管我在代码中设置了值,但实际上看不到该字段中设置的任何值。
def test_TapVisaCardOnTheReader(Process):
ResponseResults = namedtuple('ResponseResults',['STATUS', 'ISO8583', 'TOKEN', 'ICC_PUBLIC_KEY'])
ResponseResults('01', True, True, True)
TapResponseResults=Process.TappingPaymentCardOntheReader(' Visa-Card ')
assert ((ResponseResults.STATUS == TapResponseResults.STATUS) and (
ResponseResults.ISO8583 == TapResponseResults.ISO8583) and (
ResponseResults.TOKEN == TapResponseResults.TOKEN) and (
ResponseResults.ICC_PUBLIC_KEY == TapResponseResults.ICC_PUBLIC_KEY))
请检查下面的调试输出窗口,在该窗口中我没有看到任何设置。
另外我还有一个关于namedtuple
字段比较的问题,在我的代码中,我不得不比较namedtuple
的每个字段,而没有任何方法可以一次比较namedtuple
的所有字段。
在代码的这一部分中,您创建了ResponseResults对象而不保存它: