-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestFizzBuzzVariantReturn4.py
More file actions
148 lines (125 loc) · 5.13 KB
/
TestFizzBuzzVariantReturn4.py
File metadata and controls
148 lines (125 loc) · 5.13 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# AUTOGENERATED FILE -- RENAME OR YOUR EDITS WILL BE OVERWRITTEN
import unittest, exemplar
actual_io_trace = '' # Receives test values print()'ed and input().
global_input = [] # Assigned in each test to provide input() values to the function under test.
# 3 functions unchanged from starter:
# print() is mocked to see if the tests recreate the .exem-specified i/o in actual_io_trace.
def print(line="") -> None:
global actual_io_trace
if line is str:
line = line.translate(str.maketrans({"'": r"\'"})) # Escape single quotes
actual_io_trace += ">" + str(line) + '\n'
# input() is mocked to return the test-specified input as well as add it to actual_io_trace.
def input(variable_name: str = "") -> str:
# (variable_name is ignored because it may not have been specified by the .exem.)
global actual_io_trace
result = global_input.pop(0)
result = result.translate(str.maketrans({"'": r"\'"})) # Escape single quotes
actual_io_trace += "<" + result + '\n' # Eg, '<Albert\n'
return result
# The generated function under Stage 2 (i.e., a test per example) testing.
def fizz_buzz_variant_return_4():
i1 = int(input("i1:")) # Eg, 15
if i1%3==0 and i1%5==0:
print('FizzBuzz')
return 'FizzBuzz'
elif i1%3==0:
print('Fizz')
return 'Fizz'
elif i1%5==0:
print('Buzz')
return 'Buzz'
else: # == elif True:
print(4)
return 4
class TestFizzBuzzVariantReturn4(unittest.TestCase):
def setUp(self):
global actual_io_trace
actual_io_trace = ''
self.maxDiff = None
def test_fizz_buzz_variant_return_44(self):
global global_input
global_input = ['15'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<15
>FizzBuzz
''', actual_io_trace)
def test_fizz_buzz_variant_return_48(self):
global global_input
global_input = ['1'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<1
>4
''', actual_io_trace)
def test_fizz_buzz_variant_return_412(self):
global global_input
global_input = ['2'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<2
>4
''', actual_io_trace)
def test_fizz_buzz_variant_return_416(self):
global global_input
global_input = ['3'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<3
>Fizz
''', actual_io_trace)
def test_fizz_buzz_variant_return_420(self):
global global_input
global_input = ['4'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<4
>4
''', actual_io_trace)
def test_fizz_buzz_variant_return_424(self):
global global_input
global_input = ['5'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<5
>Buzz
''', actual_io_trace)
def test_fizz_buzz_variant_return_428(self):
global global_input
global_input = ['6'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<6
>Fizz
''', actual_io_trace)
def test_fizz_buzz_variant_return_431(self):
global global_input
global_input = ['7'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<7
>4
''', actual_io_trace)
def test_fizz_buzz_variant_return_435(self):
global global_input
global_input = ['8'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<8
>4
''', actual_io_trace)
def test_fizz_buzz_variant_return_438(self):
global global_input
global_input = ['9'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<9
>Fizz
''', actual_io_trace)
def test_fizz_buzz_variant_return_442(self):
global global_input
global_input = ['10'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<10
>Buzz
''', actual_io_trace)
def test_fizz_buzz_variant_return_445(self):
global global_input
global_input = ['30'] # From an example of the .exem
fizz_buzz_variant_return_4() # The function under test is used to write to actual_io_trace.
self.assertEqual('''<30
>FizzBuzz
''', actual_io_trace)
if __name__ == '__main__':
unittest.main()