On 05/06/10 10:37, Damon Timm wrote: > Hi - am trying to write some unit tests for my little python project - > I had been hard coding them when necessary here or there but I figured > it was time to try and learn how to do it properly. > <snip> > This test works, however, it only runs as *one* test (which either > fails or passes) and I want it to run as 12 different tests (three for > each file type) and be able to see which key is failing for which file > type. I know I could write them all out individually but that seems > unnecessary.
One way to do what you wanted is to harness python's dynamicity and generate the methods by their names: class TestFiles(unittest.TestCase): for methname, case in somedict: def test(self): ... __dict__[methname] = test _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor