Needed class whose instances are many test cases

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Nov 11 08:04:56 EST 2005


Sumit <sumit.nanda at gmail.com> wrote:
> I have scinario like I have to Create resource(in __init__()) Before
> Running a set of testcases and then In Testcases resources are going
> to used and then It will cleared off after Running the testcases  by
> destructor __del__()

This is a poor design; your tests will each be starting in a different
state, and will likely not run the same way if run in a different
order, making them fragile.

Test cases should each run individually, from a known state, and not
depend on any other tests. You can define a fixture for several tests
in the unittest.TestCase methods setUp() and tearDown(), to establish
and clear up respectively for each test.

-- 
 \      "When I wake up in the morning, I just can't get started until |
  `\     I've had that first, piping hot pot of coffee. Oh, I've tried |
_o__)                                 other enemas..."  -- Emo Philips |
Ben Finney



More information about the Python-list mailing list