← 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:
ok, understood.

-- 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()
for line in testcases:
    case = line.strip() # get rid of linefeed
    # analyze case
    # and run your test
    # a test should return True (pass) or False (failed)
    try:
       result = runTest(case)
       testcasesNotDone.pop(0) # delete the processed entry from the list
       if result: pass.write(line)
       else: fail.write(line)
    except:
       continue

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

now, if anything happens in your "runTest(case)", that would normally end the script with an exception, we skip to the next test.
At the end the test cases, that could not be processed are written back to the file.

Be aware, that this is only protected against exceptions, that occur
inside "runTest(case)".

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