nose-devs/nose — Issue #20: Decorator @with_setup not working for test generator functions.
Author: jpellerin
Created: 2011-12-14 15:55:27+00:00
State: open

"""
Setup and teardown functions may be used with test generators. The setup and
teardown attributes must be attached to the generator function::

@with_setup(setup_func, teardown_func)
def test_generator():
...
yield func, arg, arg ...
"""

Decorator @with_setup (doc string mentioned above) is not working with test
generator functions.

On investigation it was found that, TestLoader::loadTestsFromGenerator() is
yeild'(ing) a instance of class "FunctionTestCase" without passing setUp
and tearDown arguments.

CURRENT CALL:
-------------
yield FunctionTestCase(test_func, arg=arg, descriptor=g)

PROBABLY SHOULD BE:
-------------------
FunctionTestCase(test_func, setUp=g.func_dict['setup'],
tearDown=g.func_dict['teardown'], arg=arg, descriptor=g)

What steps will reproduce the problem?
1. create a test case generator function
2. decorate it with @with_setup(setup, teardown).

What is the expected output? What do you see instead?
- I expect setup and teardown functions to be called before each and every
test case generated.

- Instead no call to setup and teardown is being made

What version of the product are you using? On what operating system?
- nose-0.10.1, Windows XP

Please provide any additional information below.
- None

Google Code Info:
Issue #: 202
Author: vem...@gmail.com
Created On: 2008-08-19T19:40:05.000Z
Closed On: