[TIP] get fixtures for each parameter or global variables?
tiago.ferraz at gmail.com
Sat Oct 22 10:16:43 PDT 2016
Inheritance makes the most OO sense in this application, but I would
recommend to create a singleton (
and compose with this singleton object where needed. You would have more
flexibility, for example.
On Sat, Oct 22, 2016 at 6:54 PM, Ben Finney <ben+python at benfinney.id.au>
> James <bjlockie at lockie.ca> writes:
> > On 2016-10-21 08:17 PM, Ben Finney wrote:
> > I'm trying to gain ease of use since all my tests will need the same
> > variables that contain the command line options.
> That's what inheritance is for:
> * Define a class which inherits from unittest.TestCase. Have one of its
> methods (probably ‘setUp’) do the common processing you want for every
> test case instance.
> * Define your test case classes to inherit from the above class.
> class unittest.TestCase(object)
> class foo.Foo_BaseTestCase(unittest.TestCase)
> class foo.LoremIpsum_TestCase(foo.Foo_BaseTestCase)
> class foo.DolorSitAmet_TestCase(foo.Foo_BaseTestCase)
> That way, the special set-up you speak of will be defined in one place;
> any other class that needs it simply refers (by inheritance) to that
> same place and doesn't need to define it again.
> \ “We can't depend for the long run on distinguishing one |
> `\ bitstream from another in order to figure out which rules |
> _o__) apply.” —Eben Moglen, _Anarchism Triumphant_, 1999 |
> Ben Finney
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python