mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
Add tests for utils.iter.choice.
This commit is contained in:
parent
9ed5efaaef
commit
568ebcdf96
@ -379,6 +379,27 @@ class IterTest(SupyTestCase):
|
|||||||
def testRandomChoice(self):
|
def testRandomChoice(self):
|
||||||
choice = utils.iter.choice
|
choice = utils.iter.choice
|
||||||
self.assertRaises(IndexError, 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):
|
## def testGroup(self):
|
||||||
## group = utils.iter.group
|
## group = utils.iter.group
|
||||||
|
Loading…
Reference in New Issue
Block a user