Ian Bicking: the old part of his blog

Comment

I agree the OOP-only interface is a pain. Many times, I'll have a large set of basic tests I'd want to include. Something like


for i in range(100):
for j in range(100):
self.assertEquals(my_add(i,j), i+j)


Having all of these in a single test that either fails or succeeds as one, is often not what I want.

I can hack this, like so:


class AddTests(unittest.TestCase):
pass

for i in range(100):
for j in range(100):
def t(self):
self.assertEqual(myadd(i,j), i+j)
setattr(AddTests, 'test_%s_%s' % (i, j), t)


but boy does that feel like a hack!

(I hope this comes out formatted OK...)
Comment on Unittest Rant
by Paul Moore