<div dir="ltr">Inheritance makes the most OO sense in this application, but I would recommend to create a singleton (<a href="http://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python">http://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python</a>) and compose with  this singleton object where needed. You would have more flexibility, for example.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 22, 2016 at 6:54 PM, Ben Finney <span dir="ltr">&lt;<a href="mailto:ben+python@benfinney.id.au" target="_blank">ben+python@benfinney.id.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">James &lt;<a href="mailto:bjlockie@lockie.ca">bjlockie@lockie.ca</a>&gt; writes:<br>
<br>
&gt; On 2016-10-21 08:17 PM, Ben Finney wrote:<br>
</span><span class="">&gt; I&#39;m trying to gain ease of use since all my tests will need the same<br>
&gt; variables that contain the command line options.<br>
<br>
</span>That&#39;s what inheritance is for:<br>
<br>
* Define a class which inherits from unittest.TestCase. Have one of its<br>
  methods (probably ‘setUp’) do the common processing you want for every<br>
  test case instance.<br>
<br>
* Define your test case classes to inherit from the above class.<br>
<br>
    class unittest.TestCase(object)<br>
      class foo.Foo_BaseTestCase(unittest.<wbr>TestCase)<br>
        class foo.LoremIpsum_TestCase(foo.<wbr>Foo_BaseTestCase)<br>
        class foo.DolorSitAmet_TestCase(foo.<wbr>Foo_BaseTestCase)<br>
<br>
That way, the special set-up you speak of will be defined in one place;<br>
any other class that needs it simply refers (by inheritance) to that<br>
same place and doesn&#39;t need to define it again.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
 \             “We can&#39;t depend for the long run on distinguishing one |<br>
  `\         bitstream from another in order to figure out which rules |<br>
_o__)               apply.” —Eben Moglen, _Anarchism Triumphant_, 1999 |<br>
Ben Finney<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.<wbr>org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/<wbr>listinfo/testing-in-python</a><br>
</div></div></blockquote></div><br></div>