mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
Added a test for random.choice behavior.
This commit is contained in:
parent
b6066a1543
commit
f61591016b
@ -49,7 +49,7 @@ string.ascii = string.maketrans('', '')
|
|||||||
import random
|
import random
|
||||||
_choice = random.choice
|
_choice = random.choice
|
||||||
def choice(iterable):
|
def choice(iterable):
|
||||||
if isinstance(iterable, list):
|
if isinstance(iterable, (list, tuple)):
|
||||||
return _choice(iterable)
|
return _choice(iterable)
|
||||||
else:
|
else:
|
||||||
n = 1
|
n = 1
|
||||||
|
@ -31,9 +31,13 @@
|
|||||||
|
|
||||||
from testsupport import *
|
from testsupport import *
|
||||||
|
|
||||||
|
import random
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
class FunctionsTest(SupyTestCase):
|
class FunctionsTest(SupyTestCase):
|
||||||
|
def testRandomChoice(self):
|
||||||
|
self.assertRaises(IndexError, random.choice, {})
|
||||||
|
|
||||||
def testReversed(self):
|
def testReversed(self):
|
||||||
L = range(10)
|
L = range(10)
|
||||||
revL = list(reversed(L))
|
revL = list(reversed(L))
|
||||||
|
Loading…
Reference in New Issue
Block a user