我试图在从文件
中读取一行后在循环中执行下面的pytest函数import pandas as pd
import pytest
def test_assert_kwh(record_xml_property):
test_df=pd.read_csv('test_function.txt',sep="|",header=0)
print(test_df.head(10))
for index,row in test_df.iterrows():
test_function=row['test_function']
test_op=row['test_op']
test_class=row['test_class']
print ( "Test Function ",test_function)
assert eval(test_function)== test_op
File1.txt内容:
test_function|test_op|test_class
fun_1(0,0)|0|data_transformation
fun_1(0,0)|1|data_transformation
虽然文件中有两行
,但Pytest只执行一次而不是两次O / p即将通过,但有两行需要测试