Let's say I have classes (which are not TestCases) that all implement "some" methods. I now want to write a single testclass that validates that all objects actually do implement "some" methods like they should.
I am aware how to test the methods themselves, but what I would like to have is a list of those classes and the tests are then executed for every class. I can imagine it to be something like this:
import unittest
class ClassOne:
def walk(param):
return param
ClassTwo = ClassOne
class_list = [ClassOne, ClassTwo]
class TestClasses(unittest.TestCase):
def test_walk():
ob = object()
for current_class in class_list:
self.assertEqual(object, current_class.walk(object))
This solution has the disadvantage that you mix asserts that aren't really related. Is there a better way to test generically?