baker
1
Guys it is very simple script , but for some reason my IF condition is not matching.
from sys import argv
import os
filename='testdata.txt'
txt=open(filename)
while 1:
line= txt.readline()
if not line:
break
line=line.strip('\n')
sp=line.split(" ")
command =sp[2]+ " " +sp[3]+ " " +sp[4]
print command
re=os.system(command)
print "output:",re
print "expected:",sp[0]
if re == exp:
print "Testcase Passed", sp[1]
else:
print "Testcase Failed", sp[1]
the if condition is always failing for me....
Where do you set exp ? ...
baker
3
opps my mistake the code is actually
from sys import argv
import os
filename='testdata.txt'
txt=open(filename)
while 1:
line= txt.readline()
if not line:
break
line=line.strip('\n')
sp=line.split(" ")
command =sp[2]+ " " +sp[3]+ " " +sp[4]
print command
re=os.system(command)
print "output:",re
print "expected:",sp[0]
if sp[0] == re:
print "Testcase Passed", sp[1]
else:
print "Testcase Failed", sp[1]
i got the indication of failure , the out put of os.system is 1 and sp[0] is '1'.
how i can handle such conditions..?
probably because of the data types. try converting sp[0] to an integer as well:
if int(sp[0]) == re: