1

从文件中读取一行后,我试图在循环中执行以下 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 即将通过,尽管有两行要测试

4

0 回答 0