Collin Winter just released context_tools, which strikes me as a step towards bridging the gap between test methods in nose and test classes in unittest/py.test/nose/etc. Currently, it can be hard to refactor tests that start as simple test methods when later you decide to use a class for a more complex setUp() function. Specifically, context_tools lets you do:
As far as wrapping a def with an argument to access what data was setup, I also had to do this for the fixture with_data() method.
It would be nice to replace that code with context_tools since it's much simpler! However, after a glance at the code I think it would break the ability to chain together already decorated nose functions. in other words:
def my_custom_setup():
whatever = 'fooz'
@nose.tools.with_setup(my_custom_setup)
@dbfixture.with_data(Foo, Bar)
def test_my_data_model(sample_data): # here we need my_custom_setup to run # but also with_data()
assert Foo.selectfirst().id == sample_data.Foo.id