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)