title: Simulate shell input for regression test
body: <p>I'm trying to setup regression testing for an app before refactoring. The function is one long mess, starting with parsing user input and performing numerous operations before giving an output. I want to test expected values given a set of inputs (including defaults), but am not sure how to simulate a user's shell input inside a test module. Here's an example of how input is taken at the start of the file:</p>
  <pre><code>def function():
      parser = ArgumentParser()
      parser.add_argument(&quot;-a&quot;, &quot;--term-a&quot;, type=float, default=0.5, help=&quot;a term relevant to output&quot;)
      parser.add_argument(&quot;-b&quot;, &quot;--term-b&quot;, type=float, default=0.05, help=&quot;a term relevant to output&quot;)
      parser.add_argument(&quot;-c&quot;, &quot;--term-c&quot;, type=int, default=2, help=&quot;a term relevant to output&quot;)
      parser.add_argument(&quot;-f&quot;, &quot;--file-a&quot;, type=str, required=True,
                       help=&quot;Input file required for output&quot;)
      args = parser.parse_args()
  
      ...
  </code></pre>