<s> import functools <EOL> import inspect <EOL> import nose <EOL> from openstack_dashboard . test . integration_tests import config <EOL> def _is_test_method_name ( method ) : <EOL> return method . startswith ( '<STR_LIT>' ) <EOL> def _is_test_cls ( cls ) : <EOL> return cls . __name__ . startswith ( '<STR_LIT>' ) <EOL> def _mark_method_skipped ( meth , reason ) : <EOL> """<STR_LIT>""" <EOL> @ functools . wraps ( meth ) <EOL> def wrapper ( * args , ** kwargs ) : <EOL> raise nose . SkipTest ( reason ) <EOL> return wrapper <EOL> def _mark_class_skipped ( cls , reason ) : <EOL> """<STR_LIT>""" <EOL> tests = [ attr for attr in dir ( cls ) if _is_test_method_name ( attr ) ] <EOL> for test in tests : <EOL> method = getattr ( cls , test ) <EOL> if callable ( method ) : <EOL> setattr ( cls , test , _mark_method_skipped ( method , reason ) ) <EOL> return cls <EOL> NOT_TEST_OBJECT_ERROR_MSG = "<STR_LIT>" "<STR_LIT>" <EOL> def services_required ( * req_services ) : <EOL> """<STR_LIT>""" <EOL> def actual_decoration ( obj ) : <EOL> if inspect . isclass ( obj ) : <EOL> if not _is_test_cls ( obj ) : <EOL> raise ValueError ( NOT_TEST_OBJECT_ERROR_MSG ) <EOL> skip_method = _mark_class_skipped <EOL> else : <EOL> if not _is_test_method_name ( obj . func_name ) : <EOL> raise ValueError ( NOT_TEST_OBJECT_ERROR_MSG ) <EOL> skip_method = _mark_method_skipped <EOL> avail_services = config . get_config ( ) . service_available <EOL> for req_service in req_services : <EOL> if not getattr ( avail_services , req_service , False ) : <EOL> obj = skip_method ( obj , "<STR_LIT>" <EOL> "<STR_LIT>" % req_service ) <EOL> break <EOL> return obj <EOL> return actual_decoration </s>
