I already know how to test specific classes in python's unittest framework. However, I am having trouble testing specific functions. Here is what I use to select classes that I want to get tested:
if __name__ == '__main__':
test_classes_to_run = [Class1, Class2, Class3]
loader = unittest.TestLoader()
suites_list = []
for test_class in test_classes_to_run:
suite = loader.loadTestsFromTestCase(test_class)
suites_list.append(suite)
big_suite = unittest.TestSuite(suites_list)
runner = unittest.TextTestRunner()
results = runner.run(big_suite)
So I tried selecting a specific function doing:
if __name__ == '__main__':
testing_class = Class1
test_classes_to_run = [Class1.function1]
loader = unittest.TestLoader()
suites_list = []
for test_class in test_classes_to_run:
suite = loader.loadTestsFromTestCase(test_class)
suites_list.append(suite)
big_suite = unittest.TestSuite(suites_list)
runner = unittest.TextTestRunner()
results = runner.run(big_suite)
but I get the following error:
TypeError: issubclass() arg 1 must be a class