, . -, , , decorators.py:
def setup_func():
"set up test fixtures"
def teardown_func():
"tear down test fixtures"
tests.py :
from decorators import setup_func, teardown_func
from inspect import getmodule
from nose.tools import with_setup
from types import FunctionType
, . , :
for k, v in globals().items():
if isinstance(v, FunctionType) and getmodule(v).__name__ == __name__:
v = with_setup(setup_func, teardown_func)(v)
, tests.py ( ) .
, , nose , . , , . . , , - , .
: , , , . , , @with_setup .. TestCase. , , , .