Skip to content
Snippets Groups Projects
Commit bbc07db1 authored by Martin Emeric's avatar Martin Emeric
Browse files

[Added] Exo 1 - fizz_buzz function and its tests

parent 05a03965
No related branches found
No related tags found
No related merge requests found
def fizz_buzz(number: int):
if isinstance(number, int) is False:
raise TypeError('The paramter "number" must be an integer')
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz'
if number % 3 == 0:
return 'Fizz'
if number % 5 == 0:
return 'Buzz'
return number
import pytest
from tdd_exo_1 import fizz_buzz
class TestFizzBuzz:
def test_number_not_int(self):
with pytest.raises(TypeError):
fizz_buzz('not_an_int')
def test_3_multiple(self):
assert fizz_buzz(6) == 'Fizz'
def test_5_multiple(self):
assert fizz_buzz(20) == 'Buzz'
def test_3_and_5_multiple(self):
assert fizz_buzz(15) == 'FizzBuzz'
def test_no_multiple(self):
assert fizz_buzz(7) == 7
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment