[TIP] testing __init__
fuzzyman at voidspace.org.uk
Sat Apr 10 06:47:32 PDT 2010
On 10/04/2010 01:54, Alfredo Deza wrote:
> I am having issues testing the constructor of a class that has a
> try/except block.
> Should __init__ raise an exception so I can catch via
> self.assertRaises to make it easier to test? Or are there other ways
> to make __init__ "testable"?
> What is the way you guys use the most (or like the best) for testing
Well, avoiding doing things like that in constructors is one way to make
them more testable. Another way is to factor that code into a separate
method so that it can be stubbed out (test your constructor calls it)
and also tested separately.
> Alfredo Deza
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python