title: Python 3 unittest simulate user input
body: <p>How can I simulate user input in the middle of a function called by a unit test (Using Python 3's unittest)? For example, I have a function <code>foo()</code> who's output I'm testing. In the <code>foo()</code> function, it asks for user input: </p>
  
  <blockquote>
    <p><code>x = input(msg)</code></p>
  </blockquote>
  
  <p>And the output is based on the input:</p>
  
  <blockquote>
    <p><code>print("input: {0}".format(x))</code></p>
  </blockquote>
  
  <p>I would like my unit test to run <code>foo()</code>, enter an input and compare the result with the expected result.</p>