Python Unit-tests are running twice when run created test suite

+2 votes

[as I created test suite and generate a test report using HTMLTestRunner (Also modified little bit by me) single test run twice.] for that code (test suite) is:

import os
import time
import unittest
from xyz.base import log
from builtins import dir
from xyz.HTMLTestRunner import HTMLTestRunner

from xyz.tests.test.test_01 import TC01

class HTestSuite(unittest.TestCase):'Running demo test suite')

    dir = os.getcwd()
    testLoad = unittest.TestLoader()
    test_classes_to_run =[TC01]

    suites_list = []
    for test_class in test_classes_to_run:
        suite = testLoad.loadTestsFromTestCase(test_class)
    newSuite = unittest.TestSuite(suites_list)
    timestr = time.strftime("_%Y-%m-%d_%H.%M.%S")
    resultFile = open(os.path.join(dir, "TestReport"+ timestr + ".html"), "w")
    runner = HTMLTestRunner(stream=resultFile, title='test report', description='Tests Execution Report')

if __name__ == "__main__":
Jul 14, 2020 in Software Testing by Raghvir
• 170 points

1 answer to this question.

0 votes

Hey @Raghvir, this might probably be because you have the unittest.main that executes it first, and then it would execute by the tesrunner. I don't think you need the HTestSuite in the first place. 

Hope this helps!

answered Jul 14, 2020 by Kim

Related Questions In Software Testing

+1 vote
0 answers

Automation test scripts are failing in linux

Hi Team, All test script are running properly ...READ MORE

May 28 in Software Testing by Sri
• 3,190 points
+1 vote
2 answers

What are the different software testing types?

we have 2 types of testing . Functional ...READ MORE

answered Sep 1, 2020 in Software Testing by Sri
• 3,190 points
+1 vote
2 answers

What are the advantages of Functional Testing?

In simple words , expected result and actual ...READ MORE

answered Sep 1, 2020 in Software Testing by Sri
• 3,190 points
+1 vote
2 answers

What are the limitation of Functional testing?

It should mention in ur story only ...READ MORE

answered Sep 1, 2020 in Software Testing by Sri
• 3,190 points
+1 vote
2 answers

Why automation? exactly what we test?

Hey, Automation testing is used to overcome the ...READ MORE

answered May 24, 2019 in Software Testing by Abha
• 28,060 points
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,477 views
0 votes
1 answer