File tree Expand file tree Collapse file tree 2 files changed +2
-33
lines changed
Expand file tree Collapse file tree 2 files changed +2
-33
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/python3
22
3- from typing import Iterable
4- from itertools import count , islice
5-
63
74def fizzbuzz (num : int ) -> str :
85 return ('Fizz' * int (num % 3 == 0 ) + 'Buzz' * int (num % 5 == 0 )) or str (num )
96
107
11- def fizzbuzz_loop () -> Iterable [str ]:
12- return map (fizzbuzz , count (1 ))
13-
14-
158def main () -> None :
16- for value in islice ( fizzbuzz_loop () , 100 ):
17- print (value )
9+ for value in range ( 1 , 100 + 1 ):
10+ print (fizzbuzz ( value ) )
1811
1912
2013if __name__ == "__main__" :
Original file line number Diff line number Diff line change 22
33import unittest
44from unittest .mock import call , patch
5- from itertools import islice
65
76import fizzbuzz
87
@@ -18,29 +17,6 @@ def test(self):
1817 self .assertEqual (f (15 ), 'FizzBuzz' )
1918
2019
21- class TestFizzBuzzLoop (unittest .TestCase ):
22- def test (self ):
23- expected = [
24- '1' ,
25- '2' ,
26- 'Fizz' ,
27- '4' ,
28- 'Buzz' ,
29- 'Fizz' ,
30- '7' ,
31- '8' ,
32- 'Fizz' ,
33- 'Buzz' ,
34- '11' ,
35- 'Fizz' ,
36- '13' ,
37- '14' ,
38- 'FizzBuzz' ,
39- ]
40- actual = list (islice (fizzbuzz .fizzbuzz_loop (), len (expected )))
41- self .assertEqual (expected , actual )
42-
43-
4420class TestMain (unittest .TestCase ):
4521 @patch ('fizzbuzz.print' )
4622 def test (self , mock_patch ):
You can’t perform that action at this time.
0 commit comments