This code keeps reading input until 0 is given. The numbers are put in array l. I want to count the max element.
#main.py
if __name__ == "__main__":
l = list()
while True:
x = int(input())
if x == 0:
break
else:
l.append(x)
maxi = max(l)
count = 0
for i in range(len(l)):
if l[i] == maxi:
count += 1
print(count)
How to write pytest for this? Actually 2 tests. I want it to be in good TDD manner.
first test case: 1 7 9 0 answer should be 1
2nd test case: 1 3 3 1 0 answer should be 2
for the 1st case:
import pytest
from main import main_function
assert(main_function([1, 7, 9, 0])) == 1
I dont know how to make my test case accept input as in actual function main.py