[Python-Dev] setUpClass and setUpModule in unittest

Robert Collins robertc at robertcollins.net
Sat Feb 13 12:00:06 CET 2010

On Sat, 2010-02-13 at 10:42 +0000, Antoine Pitrou wrote:
> Robert Collins <robertc <at> robertcollins.net> writes:
> > 
> > I'm not personally very keen on inspecting everything in self.__dict__,
> > I suspect it would tickle bugs in other unittest extensions. However I'm
> > not really /against/ it - I don't think it will result in bad test
> > behaviour or isolation issues. So if users would like it, lets do it.
> Why not take all resource_XXX attributes?

Sure, though if we're just introspecting I don't see much risk
difference between resource_XXX and all XXX. As I say above I'm happy to
do it if folk think it will be nice.

> By the way, how does a given test access the allocated resource? Say, the DB
> connection. Does it become an attribute of the test case instance?

yes. Given 

class Foo(TestCase):
    resources = {'thing', MyResourceManager()}
    def test_foo(self):

self.thing will access the resource returned by MyResourceManager.make()

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100213/1d722b70/attachment.pgp>

More information about the Python-Dev mailing list