Having issue using Htmltestrunner and unittest in Sikuli IDE 1.1.3

Asked by Ali Ahmed on 2020-12-31

I am getting this error message when I try to run test. I am pretty with using Sikuli and python for testing. I would appreciate the help. Here is my code. I commentedout some of the lines to see if it would run if I made some adjustments.

Here is the error message I'm getting:

[error] Error caused by: Traceback (most recent call last): File "C:\SikuliX\TestHtmlRunner.sikuli\TestHtmlRunner.py", line 57, in <module> unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:\\Sikuli')) File "C:\Users\ali.ahmed\AppData\Roaming\Sikulix\Lib\unittest\main.py", line 95, in __init__ self.runTests() File "C:\Users\ali.ahmed\AppData\Roaming\Sikulix\Lib\unittest\main.py", line 234, in runTests sys.exit(not self.result.wasSuccessful()) SystemExit: False

Code Below:

import os
import sys
import time
import shutil


if not dir in sys.path: sys.path.append(dir)

#from XMLTestRunner1 import *

#import xmlrunner

#from xmlrunner import *

import unittest

import utils


import HTMLTestRunner


class Test(unittest.TestCase):
    def setUp(self):
        Debug.info('Setup Called')

if __name__ == '__main__':
#suite= unittest.TestLoader().loadTestFromTestCase(Test)

#runner= HTMLTestRunner.HTMLTestRunner(stream =fp,verbosity=3,dirTestScreenshots=dir)

Question information

English Edit question
SikuliX Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

SikuliX 1.1.3 is no longer supported. Please use 2.0.4 according to the download page.

Make some basic tests with minimal scripts and then move into more complex constructs.

reload() is generally not needed for any Python module, that is not changed, while SikuliX IDE is running.
even for imported scripts, that are open and changed in the same IDE session, with 2.0.4 even there is no reload() necessary (done internally automatically.

like so:

import HTMLTestRunner
import unittest

class MyTest(unittest.TestCase):
    def test1(self):
        assert True
    def test2(self):
        assert False

suite= unittest.TestLoader().loadTestFromTestCase(MyTest)

runner= HTMLTestRunner.HTMLTestRunner()

If this works, go on with your ideas.

Ali Ahmed (ali13xii) said : #2

I'm using the 2.0.4 and I tried to code above that you written but I'm getting an error.

[error] script [ Testcode ] stopped with error in line 10
[error] AttributeError ( 'TestLoader' object has no attribute 'loadTestFromTestCase' )
[error] --- Traceback --- error source first
line: module ( function ) statement
10: main ( <module> ) suite= unittest.TestLoader().loadTestFromTestCase(MyTest)
[error] --- Traceback --- end --------------

Ali Ahmed (ali13xii) said : #3

And I tried it with my original code and I'm getting the following error:

[error] script [ Testtest1 ] stopped with error in line 34
[error] NameError ( name 'HtmlTestRunner' is not defined )
[error] --- Traceback --- error source first
line: module ( function ) statement
34: main ( <module> ) unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:\\Sikuli'))
[error] --- Traceback --- end --------------

RaiMan (raimund-hocke) said : #4

there is a new question on that issue

Ali Ahmed (ali13xii) said : #5

Ok i found old question, that helped me resolve issue