HTMLTestRunner import problem "syntax - mismatched input"

Asked by Christoph

Hi

I'm completely new to sikuli and I'm trying to use the HTMLTestRunner. My problem is that I can't import neither the unittest.py nor the HTMLTestRunner.py. When I add

import HTMLTestRunner

to my file I get the following error:

[error] script [ sikulix ] stopped with error in line 334 at column 52
[error] SyntaxError ( "mismatched input ',' expecting NAME", )

I have searched but found nothing. Is there something I am missing? Something I don't get?

Hopefully someone here can help me out or had similar problems in the past.
I'm using SikuliX IDE Version 2.0.4

Thanks
Chris

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

There might be a syntax error on the line before (look for a comma, that is misplaced).

Revision history for this message
Christoph (chris961234) said :
#2

The syntax error disappeared in a magic way. I don't know the reason for that. However I get a different error now:

[debug] Runing test A
[error] script [ test ] stopped with error at line --unknown--
[error] --UnKnown-- ( --UnKnown-- )
[debug] RunTime:***** running cleanUp *****

when I run the following minimalistic script:

import HTMLTestRunner
import unittest

class UITestCases(unittest.TestCase):

    def test_A(self):
        Debug.info('Runing test A')

suite = unittest.TestLoader().loadTestsFromTestCase(UITestCases)
outfile = open("results.html", "w")
runner = HTMLTestRunner.HTMLTestRunner(stream = outfile, title = 'test testreport', description = 'NEW').run(suite)

Pros: I get a correct html report.

But I wonder what the unknown error is about.

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

I guess the problem comes from

import unittest

which is not needed with HTMLTestRunner (is already imported here).

Revision history for this message
Christoph (chris961234) said :
#4

Hmm... Then I get: [error] NameError ( name 'unittest' is not defined )

at the line where I use unittest.TestCase for the first time.

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

Sorry for misleading:
of course the import unittest is needed.

try as
import unittest
import HTMLTestRunner

and place this 2 lines at the top of the script.

Save you work and restart the IDE, to be sure, the imports are refreshed.

Revision history for this message
Christoph (chris961234) said :
#6

Moved import unittest above HTMLTestRunner and getting the same error (unknown error)

Cant really see why this is happening. I have also tried to delete the IDE and downloaded it again. Wich obviously didn't help either.

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

I have found the reason for the "unknown error": It is not your fault, but a problem between the HTMLTestRunner and how we are running scripts, that can be aborted using a hotkey.

As long as you get the results you are expecting, just ignore this error.

I will try to fix it in 2.0.5

Revision history for this message
Christoph (chris961234) said :
#8

The results are fine so there is no big problem right now.

Thank you RaiMan I really appreciate the work you are doing!

Revision history for this message
Christoph (chris961234) said :
#9

Thanks RaiMan, that solved my question.