Skip to content

Commit 0330e8f

Browse files
committed
testing generator
1 parent 71e7f48 commit 0330e8f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_fizzbuzz.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python
22

33
import unittest
4+
from itertools import islice
45

56
import fizzbuzz
67

@@ -17,5 +18,24 @@ def test(self):
1718
self.assertEqual(f(15), 'FizzBuzz')
1819

1920

21+
class TestFizzBuzzLoop(unittest.TestCase):
22+
23+
def test(self):
24+
expected = [
25+
'1',
26+
'2',
27+
'Fizz',
28+
'4',
29+
'Buzz',
30+
]
31+
actual = take(len(expected), fizzbuzz.fizzBuzzLoop())
32+
self.assertEqual(expected, actual)
33+
34+
35+
def take(n, iterable):
36+
"Return first n items of the iterable as a list"
37+
return list(islice(iterable, n))
38+
39+
2040
if __name__ == "__main__":
2141
unittest.main()

0 commit comments

Comments
 (0)