-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_fizzbuzz.py
99 lines (82 loc) · 2.35 KB
/
test_fizzbuzz.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class FizzBuzz():
def is_multiple(self, divisor, number):
return number % divisor == 0
def is_fizz(self, number):
return self.is_multiple(3, number)
def is_buzz(self, number):
return self.is_multiple(5, number)
def is_bang(self, number):
return self.is_multiple(7, number)
def say(self, number):
if self.is_bang(number) and self.is_buzz(number) and self.is_fizz(number):
return "fizzbuzzbang"
if self.is_buzz(number) and self.is_fizz(number):
return "fizzbuzz"
if self.is_fizz(number) and self.is_bang(number):
return "fizzbang"
if self.is_buzz(number) and self.is_bang(number):
return "buzzbang"
if self.is_fizz(number):
return "fizz"
if self.is_buzz(number):
return "buzz"
if self.is_bang(number):
return "bang"
return str(number)
#Test can say
def test_can_say_one():
fb = FizzBuzz()
one = fb.say(1)
assert one == "1"
def test_can_say_fizz_for_three():
fb = FizzBuzz()
fizz = fb.say(3)
assert fizz == "fizz"
def test_can_say_fizz_for_six():
fb = FizzBuzz()
fizz = fb.say(6)
assert fizz == "fizz"
def test_can_say_buzz_for_five():
fb = FizzBuzz()
buzz = fb.say(5)
assert buzz == "buzz"
def test_can_say_fizzbuzz_for_fifteen():
fb = FizzBuzz()
fizzbuzz = fb.say(15)
assert fizzbuzz == "fizzbuzz"
def test_can_say_fizzbang_for_twentyone():
fb = FizzBuzz()
fizzbang = fb.say(21)
assert fizzbang == "fizzbang"
def test_can_say_buzzbang_for_thirthyfive():
fb = FizzBuzz()
buzzbang = fb.say(35)
assert buzzbang == "buzzbang"
def test_can_say_bang_for_seven():
fb = FizzBuzz()
bang = fb.say(7)
assert bang == "bang"
#Test is multiple
def test_is_multiple_of_three():
fb = FizzBuzz()
divisor = 3
number = 9
_true = fb.is_multiple(divisor, number)
assert _true == True
#Test is fizz / buzz / bang
def test_is_fizz_for_3():
fb = FizzBuzz()
_true = fb.is_fizz(12)
assert _true
def test_is_buzz_for_5():
fb = FizzBuzz()
_true = fb.is_buzz(20)
assert _true
def test_is_fizzbang_for_21():
fb = FizzBuzz()
_true = fb.is_bang(21)
assert _true
def test_isfizzbuzzbang_for_105():
fb = FizzBuzz()
fbb = fb.say(105)
assert fbb == "fizzbuzzbang"