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

Bug #824185 reported by Jonathan Sternberg on 2011-08-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sikuli
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.

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) on 2012-11-02
Changed in sikuli:
status: New → In Progress
assignee: nobody → RaiMan (raimund-hocke)
RaiMan (raimund-hocke) on 2012-11-02
tags: added: scriptrun
RaiMan (raimund-hocke) on 2013-02-21
Changed in sikuli:
importance: Undecided → Low
tags: added: jython
RaiMan (raimund-hocke) on 2013-02-21
Changed in sikuli:
importance: Low → High
milestone: none → x1.0
RaiMan (raimund-hocke) on 2013-05-14
Changed in sikuli:
importance: High → Low
milestone: x1.0 → x1.1
RaiMan (raimund-hocke) on 2015-09-17
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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers