← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #172559]: logging result of assert

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- use unit test feature of IDE or the Jython module unit test directly
this feature contains a summary about the asserts ending a test case.

--- when using assert in normal workflow
assert produces an assertion exception, that can be catched with try:except:
assert(True)
try:
    assert(False)
except AssertionError:
    print "something went wrong"

conclusion:
if not in unit testing, normally assert only makes things complicated. It can be used to insert checkpoints during development, to assure things are going well. but then it is sufficient to get the assert exception stop the script.

recommendation:
use something like:
if not exists(<some-image>): print "something went wrong"; exit(1)
match = getLastMatch() # use it to carry on

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