[2.0.1] HTMLTestRunner: stream.close(): AttributeError ( '_TestResult' object has no attribute 'isAborted' )

Asked by Shresth Suman on 2019-12-09

SikuliX version - 2.0.1
Jython version - 2.7.1
Virutal Machine - Ubuntu 18.04.3 LTS

Code -

# Paths of timeNET, PetriNet Models have to be set in the test script
localtime = time.localtime(time.time())
timestring = time.strftime ('%d-%m-%Y_%H-%M-%S')

#Directory in which all the .sikuli folders are present
dir = "/home/suman/Desktop/Automated-Testing-TimeNET/TimeNET-TestCases/"

from sikuli import*
import os
import unittest
import HTMLTestRunner

###########
## Class 1 ##
###########
class TimeNet_Open(unittest.TestCase):

    #Case1
    def test_TimeNet_Open(self):
        import TimeNET_Open

###########
## Class 11 ##
###########
class CloseTimeNET(unittest.TestCase):
    #Case1
    def test_timenet_close(self):
        import TimeNET_Close

#############################
## TestLoad and TestSuite ##
#############################
suite = unittest.TestLoader().loadTestsFromTestCase(TimeNet_Open)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CloseTimeNET))

outfile = open("/home/suman/Desktop/Automated-Testing-TimeNET/Continuous_Integration_Server/TestResults/Testing/Report_Linux_"+timestring+".html","w")
runner = HTMLTestRunner.HTMLTestRunner(stream = outfile, title = 'TimeNET Test Suite', verbosity=2).run(suite)
outfile.close()

NOTE - - Everything runs fine. Test report is also generated in the mentioned directory. However, the message consoles shows this below error -

[log] TYPE "t"
[log] TYPE "cd /home/suman/Desktop/Automated-Testing-TimeNET/TimeNET-4.5/TimeNET/bin/#ENTER."
[log] TYPE "sudo ./startGUI#ENTER."
[log] TYPE "suman#ENTER."
[log] CLICK on L[1877,8]@S(0) (630 msec)
[log] CLICK on L[1899,10]@S(0) (565 msec)
ok test_TimeNet_Open (__main__.TimeNet_Open)
ok test_timenet_close (__main__.CloseTimeNET)

Time Elapsed: 0:00:30.699000
[error] script [ TestRunner ] stopped with error in line 38
[error] AttributeError ( '_TestResult' object has no attribute 'isAborted' )
[error] --- Traceback --- error source first
line: module ( function ) statement
38: main ( <module> ) outfile.close()
[error] --- Traceback --- end --------------

NOTE - Everything runs fine. Test report is also generated in the mentioned directory. However, the message consoles shows this above error.

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-12-09
Last reply:
2020-01-13
RaiMan (raimund-hocke) said : #1

apparently the close() makes the problem.

So just leave it out or find out, why this happens.

Run your script from commandlin. At scriptend, the stream is closed anyways.

I do not accept bugs/enhancements for HTMLTestRunner (not my package)

Shresth Suman (shsu7085) said : #2

Hi,
Thank you for your reply.
I just checked the same code with sikulix version 1.1.4 and Jython version - 2.7.1 on Windows 10 as well as Ubuntu 18.04 machines. No error was there. Everything worked fine.

Since was I working with sikulix 1.1.4 for a very long time I thought to upgrade it recently, but after upgrading to sikulix 2.0.1, GUI testing worked and also generated an HTML test report. However, there was an error in the message console.

Maybe something with the current version of SikuliX?

I will stick to version 1.1.4 for now.

RaiMan (raimund-hocke) said : #3

ok, thanks for feedback.

I will try to check what might be wrong.

TestMechanic (ndinev) said : #4

He is the solution: in htmltestrunner.py locate the main class and add "isAborted" method.

Here is an example:

class HTMLTestRunner(Template_mixin):
    """
    """
    def isAborted(self):
        return False

    def __init__(self, stream=sys.stdout, verbosity=1, title=None, description=None):

Can you help with this problem?

Provide an answer of your own, or ask Shresth Suman for more information if necessary.

To post a message you must log in.