From 568ebcdf965b2c1a6425e8ca99e7f45c702546d4 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 18 Feb 2005 13:40:29 +0000 Subject: [PATCH] Add tests for utils.iter.choice. --- test/test_utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_utils.py b/test/test_utils.py index cf148e17b..9777827ea 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -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