I have a method that takes user inputs and validates them until they enter a correct value. I am not sure how to write a unit test for this method since it already validates the user input.
def refreshtime_validation():
while True:
try:
runtime_input = float(raw_input("Enter Refresh Time (in seconds): "))
except ValueError:
print "\n**Please enter a valid number (Must be an integer).**\n"
continue
if runtime_input <= 0:
print "\n**Please enter a valid number (Must be greater than 0).**\n"
continue
else:
return runtime_input
How do I go about in writing a unit test for this method? The only one I have so far is
self.assertEquals('1','1')
self.assertEquals('100','100')
self.assertEquals('100000','100000')