TypeError: 'NoneType' object is not callable - from HTML test runner

Asked by Asheru on 2019-01-21

Hello, i am using Sikuli,unittest and HTMLTestRunner . I have a CSV file that looks like this for example:

startApp,createNewProject
startApp,createNewProject,createDiagram

For each line in the CSV I'm creating a test. The code is this:

def TestSuiteFactory():
    suite = unittest.TestSuite()
    pathCSV = r'pathToCsv\testCSV.csv'
    with open(pathCSV, 'rb') as csvfile:
        sequenceInnerMethods = dict()
        reader = csv.reader(csvfile)
        for row in reader:
            for item in row:
                try:
                    sequenceInnerMethods[item] = getattr(HagercadSteps.Steps, item)()
                    #getattr(HagercadSteps.Steps, item)()
                except AttributeError:
                    print("Unknown attribute", item, "ignored")
            sequenceTestSuite = __builtin__.type(row[-1], (unittest.TestCase,), sequenceInnerMethods)
            suite.addTest(sequenceTestSuite(item))
            #HagercadSteps.Steps.stopApp()
        return suite

So here there 2 tests that will be built and run with the help of this method. The problem is that inside the html test report, for each test i get this error:

TypeError: 'NoneType' object is not callable

I couldn't find proper solutions for this. Anyone has an idea?

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-01-21
Last reply:
2019-01-22
Asheru (asheru93) said : #1

Forgot to add the code for main:

if __name__== "__main__":
        myClass.createFolder(HagercadConfig.HAGERCAD_TEST_REPORTS_FOLDER)
        unittest.TextTestRunner(verbosity = 2)
        output = open(HagercadConfig.HAGERCAD_HTML_REPORT_FILE,"w+")
        runner = HTMLTestRunner.HTMLTestRunner(stream=output, title=HagercadConfig.HAGERCAD_HTML_REPORT_TITLE, description=HagercadConfig.HAGERCAD_HTML_REPORT_DESCRIPTION,
                dirTestScreenshots=HagercadConfig.HAGERCAD_TEST_REPORTS_FOLDER)

        runner.run(HagercadTestSuites.TestSuiteFactory())

Asheru (asheru93) said : #2

This comes apparently from HTMLTestRunner.py line 678:

           def run(self, test):
                  "Run the given test case or test suite."
                   result = _TestResult(self.verbosity, self.dirTestScreenshots) # modified by RaiMan
                   test(result) #line 678
                   self.stopTime = datetime.datetime.now()
                  #print >>sys.stderr, result.result
                  self.generateReport(test, result)
                  print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
                  return result

Still can't figure out how to solve it

RaiMan (raimund-hocke) said : #3

I am not really able to work still for the next 2 days.

Apparently in the inner call the parameter test is None, which in turn must be the result of your Suite construction.

I will try to come back asap.

Asheru (asheru93) said : #4

No problem. I found a solution for this, i will come back with a detailed answer when I have time.

Can you help with this problem?

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

To post a message you must log in.