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 378443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:47:37+00:00 2026-05-12T14:47:37+00:00

I have a utility class that stores methods that are useful for some unit

  • 0

I have a utility class that stores methods that are useful for some unit test cases. I want these helper methods to be able to do asserts/fails/etc., but it seems I can’t use those methods because they expect TestCase as their first argument…

I want to be able to store the common methods outside of the testcase code and continue to use asserts in them, is that possible at all? They are ultimately used in testcase code.

I have something like:

unittest_foo.py:

import unittest
from common_methods import *
class TestPayments(unittest.TestCase):
 def test_0(self):
  common_method1("foo")

common_methods.py:

from unittest import TestCase
def common_method1():
    blah=stuff
    TestCase.failUnless(len(blah) > 5)
        ...
...

When the suite is run:

TypeError: unbound method failUnless() must be called with TestCase instance as first argument (got bool instance instead)

  • 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-12T14:47:38+00:00Added an answer on May 12, 2026 at 2:47 pm

    Sounds like you want this, from the error at least …

    unittest_foo.py:

    import unittest
    from common_methods import *
    
    class TestPayments(unittest.TestCase):
        def test_0(self):
            common_method1(self, "foo")
    

    common_methods.py:

    def common_method1( self, stuff ):
        blah=stuff
        self.failUnless(len(blah) > 5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a static methods class, Utils, that is basically for utility methods, its
I have a utility class with some static methods which I use in some
I have a utility class that creates & returns a db connection: Public Shared
I have a utility class that needs to work on a generic Class but
Anyone have a suggestion for a good utility class that maps values from one
I have a class with only class methods (utility stuff), so my interface is
I have created a utility method that contains some try/catches in it. In those
Within a namespace I have a utility class that is only functional to a
I have the following code. The intent is to have this utility class that
I have a utility class that takes a constructor parameter of an interface to

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.