Python unittest: Generate multiple tests programmatically? [duplicate]
问题 Possible Duplicate: How to generate dynamic (parametrized) unit tests in python? I have a function to test, under_test , and a set of expected input/output pairs: [ (2, 332), (234, 99213), (9, 3), # ... ] I would like each one of these input/output pairs to be tested in its own test_* method. Is that possible? This is sort of what I want, but forcing every single input/output pair into a single test: class TestPreReqs(unittest.TestCase): def setUp(self): self.expected_pairs = [(23, 55), (4,