Add tests for utils.iter.choice.

This commit is contained in:
James Vega 2005-02-18 13:40:29 +00:00
parent 9ed5efaaef
commit 568ebcdf96

View File

@ -379,6 +379,27 @@ class IterTest(SupyTestCase):
def testRandomChoice(self):
choice = utils.iter.choice
self.assertRaises(IndexError, choice, {})
L = [1, 2]
i = iter(L)
L1 = False
L2 = False
i1 = False
i2 = False
for n in xrange(100):
ans = choice(L)
if ans == 1:
L1 = True
else:
L2 = True
ans = choice(i)
if ans == 1:
i1 = True
else:
i2 = True
self.assertEqual(L1 and L2, True,
'utils.iter.choice isn\'t being random with lists')
self.assertEqual(i1 and i2, True,
'utils.iter.choice isn\'t being random with iterables')
## def testGroup(self):
## group = utils.iter.group