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

  • SEARCH
  • Home
  • 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 9137939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:11:31+00:00 2026-06-17T09:11:31+00:00

I have a very simple setup that uses unittest and I am getting an

  • 0

I have a very simple setup that uses unittest and I am getting an error that I don’t understand.

# mytestcase.py
import unittest

class MyTestCase(unittest.TestCase):
    def test_one(self):
        self.assertTrue(True)
    def test_two(self):
        self.assertTrue(False)


def initialize():
    return MyTestCase()

if __name__ == '__main__':
    unittest.main()

If I execute the above file, I get the following result, which I expect and understand:

> python mytestcase.py
.F
======================================================================
FAIL: test_two (__main__.MyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "mytestcase.py", line 7, in test_two
    self.assertTrue(False)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (failures=1)

But I want to run these tests another way, from my_test_manager.py:

# my_test_manager.py
import mytestcase

test_case = mytestcase.initialize()
test_suite = unittest.TestLoader().loadTestsFromTestCase(test_case)
test_suite_result = unittest.TestResult()
test_suite.run(test_suite_result)
for err in test_suite_result.errors:
    print err
for fail in test_suite_result.failures:
    print fail

But if I try to run this file, it crashes as follows:

> python my_test_manager.py 
Traceback (most recent call last):
  File "my_test_manager.py", line 3, in <module>
    test_case = mytestcase.initialize()
  File "/Users/Jon/dev/test-tools/practice/mytestcase.py", line 11, in initialize
    return MyTestCase()
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 191, in __init__
    (self.__class__, methodName))
ValueError: no such test method in <class 'mytestcase.MyTestCase'>: runTest
  • 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-06-17T09:11:31+00:00Added an answer on June 17, 2026 at 9:11 am

    You do not need to create an instance; return the MyTestCase class itself:

    def initialize():
        return MyTestCase
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple Setup project that copies three dlls into the GAC.
I have a very simple setup, a whole solution that builds using .NET 3.5.
I have a very simple asp.net mvc3 app that uses jquery::getJSON to call into
I have a very simple setup... A route is setup that calls a modal
I have a very simple ColorBox gallery setup just like the examples. Simple tags
I have a very simple script that creates a user: <?php include 'mysqlserver.php'; session_start();
I have a very simple python package that I build into debian packages using
I have a very simple case that I think would benefit from using templates
I have a Telerik RadGrid and have a very simple Hierarchical dataset that I
I have a VERY simple C# Winforms project that I made using Visual Studio

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.