我有一种方法可以接受用户输入并验证它们,直到他们输入正确的值。我不确定如何为此方法编写单元测试,因为它已经验证了用户输入。
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
我该如何为这种方法编写单元测试?到目前为止我唯一的一个是
self.assertEquals('1','1')
self.assertEquals('100','100')
self.assertEquals('100000','100000')
婷婷同学_
相关分类