[TIP] get fixtures for each parameter or global variables?
Tiago Ferraz
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 (
http://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python)
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>
wrote:
> 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
> http://lists.idyll.org/listinfo/testing-in-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20161022/73c2ca9e/attachment.html>
More information about the testing-in-python
mailing list