-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_fizz_buzz.py
49 lines (36 loc) · 1.12 KB
/
test_fizz_buzz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest
import fizz_buzz as fb
def test_wrong_type():
with pytest.raises(TypeError):
result = fb.fizz_buzz("foobar")
def test_multiple_three():
result1 = fb.fizz_buzz(3)
result2 = fb.fizz_buzz(9)
assert result1 == "Fizz"
assert result2 == "Fizz"
def test_multiple_five():
result1 = fb.fizz_buzz(5)
result2 = fb.fizz_buzz(10)
assert result1 == "Buzz"
assert result2 == "Buzz"
def test_multiple_three_and_five():
result1 = fb.fizz_buzz(15)
result2 = fb.fizz_buzz(30)
assert result1 == "FizzBuzz"
assert result2 == "FizzBuzz"
def test_not_multiple():
result1 = fb.fizz_buzz(1)
result2 = fb.fizz_buzz(4)
assert result1 == "1"
assert result2 == "4"
def test_bulk_wrong_type():
with pytest.raises(TypeError):
result = fb.fizz_buzz_bulk("foobar")
def test_bulk():
expected_outcome = [
'FizzBuzz', '1', '2', 'Fizz', '4', 'Buzz',
'Fizz', '7', '8','Fizz', 'Buzz',
'11', 'Fizz', '13', '14', 'FizzBuzz']
results = fb.fizz_buzz_bulk(15)
assert len(results) == 16
assert ''.join(expected_outcome) == ''.join(results)