[py-dev] Setup and teardown functions

Simon Callan simon.callan at infoshare-is.com
Tue May 11 11:44:27 CEST 2010


Hi,

I'm trying to understand how to implement setup() and teardown() functions,
but finding it a bit difficult.

What I want is the following:
1) A setup() teardown() executed when the test process starts and stops.
2) A setup() teardown() executed when a group of tests are started
/finished.
3) A setup() / teardown() executed when a test is run.

I.e., something like this:
global_setup()
  group1_setup()
    setup()
      test_1()
    teardown()
    setup()
      test_2()
    teardown()
    setup()
      test_3()
    teardown()
  group1_teardown()
  group2_setup()
    setup()
      test_4()
    teardown()
    setup()
      test_5()
    teardown()
    setup()
      test_6()
    teardown()
  group2_teardown()
global_teardown()

Is this possible? The documentation implies that it should be possible, but
I cannot figure it out.

Simon

Infoshare Ltd
Millennium House
21 Eden Street
Kingston upon Thames
Surrey
KT1 1BL
United Kingdom

Phone: 		+ 44 (0) 20 8541 0111
Support:	+ 44 (0) 20 8481 4760
Web:		www.infoshare-is.com
E-mail:		info at infoshare-is.com

Infoshare Ltd is registered in England and Wales.
Registered Office as above.
Registered Number 2877612
VAT Number GB 678 1443 10

The content of this e-mail (and any attachment to it) is confidential. 
Any views or opinions do not represent the views or opinions 
of Infoshare Ltd.
If you have received this e-mail in error please notify the sender 
and delete it. You may not use, copy or disclose the information 
in any way. 

Infoshare Ltd monitors incoming and outgoing e-mails.

Please consider the environment. Do you really need to print 
this email?





More information about the Pytest-dev mailing list