Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 720339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:44:49+00:00 2026-05-14T05:44:49+00:00

I have a test suite to perform smoke tests. I have all my script

  • 0

I have a test suite to perform smoke tests. I have all my script stored in various classes but when I try and run the test suite I can’t seem to get it working if it is in a class. The code is below: (a class to call the tests)

from alltests import SmokeTests 

class CallTests(SmokeTests): 

    def integration(self): 

        self.suite() 

if __name__ == '__main__': 
    run = CallTests() 
    run.integration() 

And the test suite:

class SmokeTests(): 

    def suite(self): #Function stores all the modules to be tested  
        modules_to_test = ('external_sanity', 'internal_sanity') # This is the name of the file
        alltests = unittest.TestSuite() 
        for module in map(__import__, modules_to_test): 
            alltests.addTest(unittest.findTestCases(module)) 
        return alltests 
if __name__ == '__main__': 
    unittest.main(defaultTest='suite') 

So I can see how to call a normal function defined but I’m finding it difficult calling in the suite. In one of the tests the suite is set up like so:

class TestInternalSanity(unittest.TestCase):

    def setUp(self):

        setUp script ....

    def tearDown(self):

        script .... 

class BasicInternalSanity(TestInternalSanity):

    def runTest(self):

        test script ....

class InternalSanityTestSuite(unittest.TestSuite): 

    # Tests to be tested by test suite 
    def makeInternalSanityTestSuite(): 
        suite = unittest.TestSuite() 
        suite.addTest(TestInternalSanity("BasicInternalSanity")) 
        suite.addTest(TestInternalSanity("VerifyInternalSanityTestFail")) 
        return suite 

    def suite(): 
        return unittest.makeSuite(TestInternalSanity) 

If I have def suite() inside the class SmokeTests the script executes but the tests don’t run but if I remove the class the tests run. I run this as a script and call in variables into the tests. I do not want to have to run the tests by os.system(‘python tests.py’). I was hoping to call the tests through the class I have like any other function. This need’s to be called from a class as the script that I’m calling it from is Object Oriented. If anyone can get the code to be run using Call Tests I would appreciate it alot.

This work’s:

def suite(): #Function stores all the modules to be tested  
    modules_to_test = ('external_sanity', 'internal_sanity') 
    alltests = unittest.TestSuite() 
    for module in map(__import__, modules_to_test): 
        alltests.addTest(unittest.findTestCases(module)) 
    return alltests 
if __name__ == '__main__': 
    unittest.main(defaultTest='suite') 

This does not work:

class SmokeTests():

    def suite(self): #Function stores all the modules to be tested  
        modules_to_test = ('external_sanity', 'internal_sanity') 
        alltests = unittest.TestSuite() 
        for module in map(__import__, modules_to_test): 
            alltests.addTest(unittest.findTestCases(module)) 
        return alltests 
if __name__ == '__main__': 
    unittest.main(defaultTest='suite') 

I can’t seem to get this to run in the class, can anyone see the solution.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:44:49+00:00Added an answer on May 14, 2026 at 5:44 am

    Got it working, sorry for wasting everyones time, the answer was to change the default test name.

    class SmokeTests(): 
    
        def suite(self): #Function stores all the modules to be tested   
            modules_to_test = ('external_sanity', 'internal_sanity')  
            alltests = unittest.TestSuite()  
            for module in map(__import__, modules_to_test):  
                alltests.addTest(unittest.findTestCases(module))  
            return alltests  
    if __name__ == '__main__':
        Smoke = SmokeTests()  
        unittest.main(defaultTest='Smoke.suite') 
    

    Thanks for any help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test suite to perform smoke tests. I have all my script
I have the following layout for my test suite: TestSuite1.cmd: Run my program Check
Same question as waloeiii in twitter : How can I have autospec/test not run
I have an Integration Test Suite. I have a IntegrationTestBase class for all my
I have created a Visual Studio 2008 sp1 test suite web test that uploads
I've tryed mylyn but i cant find that feature, if anyone have test mantis
I have a series of HTML tests that I am able to run using
I have a MOSS 2007 test site, its not public facing, instead its on
I have a unit test which contains the following line of code Site.objects.get(name=UnitTest).delete() and
I've got IIS7 installed and have a simple website at: c:/inetpub/wwwroot/testsite I can copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.