1

I am trying to execute the below pytest function in loop after reading a row from file

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 content :

test_function|test_op|test_class
fun_1(0,0)|0|data_transformation
fun_1(0,0)|1|data_transformation

Pytest is only getting executed once and not twice , though there are two rows in the file

O/p is coming as one passed , though there are two rows which are to be tested

phd
  • 82,685
  • 13
  • 120
  • 165
joy
  • 19
  • 3
  • 1
    Possible duplicate of [How do I run multiple Python test cases in a loop?](https://stackoverflow.com/questions/19071601/how-do-i-run-multiple-python-test-cases-in-a-loop) – asozcan Jan 09 '18 at 18:34
  • I have edited the question – joy Jan 09 '18 at 19:19
  • What makes you think the second row is not tested? What is the actual test output (what `pytest` is printing), and what did you expect to see? – hoefling Jan 19 '18 at 10:28

0 Answers0