def fake_input(inputs):
 it = iter(inputs)
 def mock_input(prompt=''):
  try:
   return next(it)
  except StopIteration:
   raise EOFError('No more inputs given')
 return patch('builtins.input', mock_input)

def fake_input ( inputs ) : it = iter ( inputs ) def mock_input ( prompt = '' ) : try : return next ( it ) except StopIteration : raise EOFError ( 'No more inputs given' ) return patch ( 'builtins.input' , mock_input )
temporarily replace the input() function to return the given values use as a context manager: with fake_input: values are returned in order .