[Twisted-Python] Re: [Twisted-commits] r15100 - So I really do want this stuff

Jonathan Lange jml at mumak.net
Sat Nov 12 21:48:13 EST 2005


On 13/11/05, Jonathan Lange <jml at mumak.net> wrote:
> On 13/11/05, James Y Knight <foom at fuhm.net> wrote:
> > On Nov 12, 2005, at 4:34 PM, Jonathan Lange wrote:
> > > On 13/11/05, James Y Knight <foom at fuhm.net> wrote:
> > >>
> > >> Maybe this is a stupid question, but I'm confused as to why the
> > >> implementation isn't straightforward, something along the lines of
> > >> the following:
> > >>

Also, I should point out that implementing setUpClass using resources
will (probably -- I haven't benchmarked) make tests run faster.

Say you have a base:

class ComplexBase(unittest.TestCase):
  def setUpClass(self):
    """do complex stuff"""

  def tearDownClass(self):
    """do complex stuff"""

class A(ComplexBase):
  def test1(self):
    pass

class B(ComplexBase):
  def test2(self):
    pass

Then, with resources, the run order will be:
    setUpClass
    test1
    test2
    tearDownClass

As opposed to:
    setUpClass
    test1
    tearDownClass
    setUpClass
    test2
    tearDownClass




More information about the Twisted-Python mailing list