X-1.0rc2: IDE: unittest.main() not usable - sys.argv is empty --- workaround --- fixed in 1.1.0

Bug #824185 reported by Jonathan Sternberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Fix Released
Critical
RaiMan

Bug Description

*** workaround:
see comment #1
---------------------------------

If using the unittest module in the Sikuli IDE, it will fail after calling unittest.main() with this backtrace.

[error] Error message: Traceback (most recent call last):
File "C:\DOCUME~1\JSTERN~1\LOCALS~1\Temp\sikuli-tmp6357708907197010851.py", line 28, in
    unittest.main()
File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\unittest.py", line 766, in __init__
IndexError: index out of range: 0

That line is:
        self.progName = os.path.basename(argv[0])

It just looks like Sikuli isn't passing the program name as the first argument and the unittest module wants that.

Revision history for this message
RaiMan (raimund-hocke) wrote :

When running a script in the IDE that uses the unit test module, you cannot use unittest.main(), you have to use

suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
unittest.TextTestRunner().run(suite)

to run your tests.

Only when running a script from command line, sys.argv is populated as expected.

So to be consistent, do not use unit test.main() generally.

summary: - IndexError in unittest.main()
+ X-1.0rc2: IDE: unittest.main() not usable - sys.argv is empty ---
+ workaround
description: updated
RaiMan (raimund-hocke)
Changed in sikuli:
status: New → In Progress
assignee: nobody → RaiMan (raimund-hocke)
RaiMan (raimund-hocke)
tags: added: scriptrun
RaiMan (raimund-hocke)
Changed in sikuli:
importance: Undecided → Low
tags: added: jython
RaiMan (raimund-hocke)
Changed in sikuli:
importance: Low → High
milestone: none → x1.0
RaiMan (raimund-hocke)
Changed in sikuli:
importance: High → Low
milestone: x1.0 → x1.1
RaiMan (raimund-hocke)
summary: X-1.0rc2: IDE: unittest.main() not usable - sys.argv is empty ---
- workaround
+ workaround --- fixed in 1.1.0
Changed in sikuli:
status: In Progress → Fix Committed
importance: Low → Critical
RaiMan (raimund-hocke)
Changed in sikuli:
status: Fix Committed → Fix Released
milestone: 1.1.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.