weird error after calling unittest.main()

Asked by Mike Thon

I set up a standard Sikuli script (not using the unit test part of the gui) by subclassing unittest.TestCase. I have defined two test case methods and I call this by calling unittest.main(). Both of the test cases run without exceptions, but after the second one finishes running, I get the following error instead of terminating normally:

Traceback (most recent call last):
 File "/var/folders/y5/530trb_n7_1bgmtgn32183hm0000gn/T/sikuli-tmp7337792079999793769.py", line 57, in
 unittest.main()
 File "/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/unittest.py", line 768, in __init__
 File "/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/unittest.py", line 806, in runTests
SystemExit: True

Any idea what causes this error?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

This is a bug of the IDE when using

Should not happen, if you run your script using
java -jar path-to-sikuli-script.jar path-to-your-script.sikuli

the path-to-... according to your situation

or you use the test runner approach (see faq 1804).

Revision history for this message
Mike Thon (mike-thon) said :
#2

Running on the command line enables me to run the tests and I can get the usual text report of the test results. However after the test report I get another error:

[error] Can't run this Sikuli script: /Users/mike/Desktop/gui2.sikuli

Even though that script has already run. Can I assume that it is safe to continue to use unit tests this way?
Thanks

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

-- Can I assume that it is safe to continue to use unit tests this way?
Yes we can ;-)
ugly but safe.

As already mentioned above:

when using a structure like this without using unittest.main(), should work without this error

import unittest

class TestA(TestCase):
...
...

suite = unittest.TestLoader().loadTestsFromTestCase(TestA) # see comment
unittest.TextTestRunner(verbosity=2).run(suite)

Revision history for this message
Mike Thon (mike-thon) said :
#4

Thanks!