[TIP] get fixtures for each parameter or global variables?
ben+python at benfinney.id.au
Sat Oct 22 09:54:39 PDT 2016
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.
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 |
More information about the testing-in-python