'perform setup for this test function.'

def setup(self):

    if hasattr(self, '_preservedparent'):
        obj = self._preservedparent
    elif isinstance(self.parent, Instance):
        obj = self.parent.newinstance()
        self.obj = self._getobj()
    else:
        obj = self.parent.obj
    if inspect.ismethod(self.obj):
        setup_name = 'setup_method'
        teardown_name = 'teardown_method'
    else:
        setup_name = 'setup_function'
        teardown_name = 'teardown_function'
    setup_func_or_method = _get_xunit_setup_teardown(obj, setup_name, param_obj=self.obj)
    if (setup_func_or_method is not None):
        setup_func_or_method()
    teardown_func_or_method = _get_xunit_setup_teardown(obj, teardown_name, param_obj=self.obj)
    if (teardown_func_or_method is not None):
        self.addfinalizer(teardown_func_or_method)
