Here's an example:
from unittest import TestCase
class DogTest(TestCase):
def create_dog(self, weight):
dog = {'weight': weight}
return dog
class DogPawTest(TestCase):
def test_dog_paw(self):
dog_test = DogTest()
dog = dog_test.create_dog(weight=10)
self.assertEqual(dog['weight'], 10)
It throws
ValueError: no such test method in <class 'unittest_case_import.DogTest'>: runTest
Test cases should be independent. Also, create_dog can and should be outside of the test class. Changing the definition to DogTest(object) solves the riddle. But I have a case where it's not an option.
How can I use the methods of another TestCase-based class in test_dog_paw?
DogPawTest(DogTest)in DogPawTest. and useself.create_dog(weight=10