← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #171648]: Search inside files and get particular data

 

Question #171648 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/171648

    Status: Open => Answered

RaiMan proposed the following answer:
If I understand right, then 2 lines in the input file together represent
a test case.

I have corrected a bug with the handling of testcasesNotDone

-- updated template:

testcasesFileName = r"c:\testcases.txt"
testcasesFile = open(testcasesFileName)
pass = open(r"c:\pass.txt", "a")
fail = open(r"c:\fail.txt", "a")

testcases = testcasesFile.readlines()
testcasesNotDone = testcasesFile.readlines()
testcasesFile.close()
notDone = 0
for i in range(0, len(testcases), 2):
    case1 = line[i].strip() # case's first line
    case2 = line[i+1].strip() # case's second line 
    # analyze case
    # and run your test
    # a test should return True (pass) or False (failed)
    try:
       result = runTest(case1, case2)
       testcasesNotDone.pop(notDone) # delete the processed entry from the list
       testcasesNotDone.pop(notDone+1) # delete the processed entry from the list
       if result: pass.write(line[i]+line[i+1])
       else: fail.write(line[i]+line[i+1])
    except:
       notDone += 2
       continue

testcasesFile = open(testcasesFileName, "w")
for line in testcasesNotDone:
    testcasesFile.write(line)
testcasesFile.close()
pass.close()
fail.close()

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.