Added a test for random.choice behavior.

This commit is contained in:
Jeremy Fincher 2004-10-10 03:55:29 +00:00
parent b6066a1543
commit f61591016b
2 changed files with 5 additions and 1 deletions

View File

@ -49,7 +49,7 @@ string.ascii = string.maketrans('', '')
import random
_choice = random.choice
def choice(iterable):
if isinstance(iterable, list):
if isinstance(iterable, (list, tuple)):
return _choice(iterable)
else:
n = 1

View File

@ -31,9 +31,13 @@
from testsupport import *
import random
import itertools
class FunctionsTest(SupyTestCase):
def testRandomChoice(self):
self.assertRaises(IndexError, random.choice, {})
def testReversed(self):
L = range(10)
revL = list(reversed(L))