Hello all,<br><br>Does anyone have advice for writing unit tests against variables set by command-line options?<br><br>I have a program I&#39;d like to run in either &quot;debug&quot; or &quot;live&quot; mode, with various settings associated with each. Below is some pseudo-code that shows what I&#39;d like to do:<br>
<br>&lt;&lt;snipped argparse import and options setup &gt;&gt;<br>mode = p.parse_args() #always set to either --debug or --live<br><br>if mode.live:<br>

    recipients = [&#39;<a href="mailto:jsmith@email.com">jsmith@email.com</a>&#39;, &#39;<a href="mailto:janedoe@email.com">janedoe@email.com</a>&#39;]<br>

    # set logging to a file<br>

elif mode.debug:<br>

    recipients = [&#39;<a href="mailto:admin@admin.com">admin@admin.com</a>&#39;]<br>

    # log to stdout<br><br>The &quot;live&quot; and &quot;debug&quot; attributes are set by command-line flags passed to the argparse module. What I&#39;d like to do is write tests that check whether various settings (recipients, logging, etc.) are configured properly based on the command-line options. <br>
<br>But if &quot;mode&quot; is not set until runtime, I clearly can&#39;t import it into my suite of unit
tests, right? Is there some standard testing approach to this problem (perhaps mocking?) that you all can recommend? <br><br>I&#39;d greatly appreciate it.<br>Serdar<br>