Skip to content

Commit

Permalink
remove 'fizzbuzz_loop' function for simplicity
Browse files Browse the repository at this point in the history
AaronRobson committed Aug 22, 2023
1 parent 5cd3254 commit 7eb90df
Showing 2 changed files with 2 additions and 33 deletions.
11 changes: 2 additions & 9 deletions fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#!/usr/bin/python3

from typing import Iterable
from itertools import count, islice


def fizzbuzz(num: int) -> str:
return ('Fizz' * int(num % 3 == 0) + 'Buzz' * int(num % 5 == 0)) or str(num)


def fizzbuzz_loop() -> Iterable[str]:
return map(fizzbuzz, count(1))


def main() -> None:
for value in islice(fizzbuzz_loop(), 100):
print(value)
for value in range(1, 100 + 1):
print(fizzbuzz(value))


if __name__ == "__main__":
24 changes: 0 additions & 24 deletions tests/test_fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import unittest
from unittest.mock import call, patch
from itertools import islice

import fizzbuzz

@@ -18,29 +17,6 @@ def test(self):
self.assertEqual(f(15), 'FizzBuzz')


class TestFizzBuzzLoop(unittest.TestCase):
def test(self):
expected = [
'1',
'2',
'Fizz',
'4',
'Buzz',
'Fizz',
'7',
'8',
'Fizz',
'Buzz',
'11',
'Fizz',
'13',
'14',
'FizzBuzz',
]
actual = list(islice(fizzbuzz.fizzbuzz_loop(), len(expected)))
self.assertEqual(expected, actual)


class TestMain(unittest.TestCase):
@patch('fizzbuzz.print')
def test(self, mock_patch):

0 comments on commit 7eb90df

Please sign in to comment.