def try_run(obj, names):
for name in names:<EOL><INDENT>func = getattr(obj, name, None)<EOL>if func is not None:<EOL><INDENT>if type(obj) == types.ModuleType:<EOL><INDENT>try:<EOL><INDENT>args, varargs, varkw, defaults = inspect.getargspec(func)<EOL><DEDENT>except TypeError:<EOL><INDENT>if hasattr(func, '<STR_LIT>'):<EOL><INDENT>func = func.__call__<EOL><DEDENT>try:<EOL><INDENT>args, varargs, varkw, defaults =inspect.getargspec(func)<EOL>args.pop(<NUM_LIT:0>) <EOL><DEDENT>except TypeError:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(name, obj))<EOL><DEDENT><DEDENT>if len(args):<EOL><INDENT>log.debug("<STR_LIT>", obj, name, obj)<EOL>return func(obj)<EOL><DEDENT><DEDENT>log.debug("<STR_LIT>", obj, name)<EOL>return func()<EOL><DEDENT><DEDENT>
Given a list of possible method names, try to run them with the
    provided object. Keep going until something works. Used to run
    setup/teardown methods for module, package, and function tests.