def check_loc(): veil_component.load_all_components() component_files = {} for module_name, module in sys.modules.items(): component_name = veil_component.get_leaf_component(module_name) if component_name and hasattr(module, '__file__'): module_file = module.__file__.replace('.pyc', '.py') module_loc = get_loc(module_file) component_files.setdefault(component_name, []).append( (module_file, module_loc)) max_loc = 0 application = get_application() ignored_app_components = getattr(application, 'LOC_CHECK_IGNORED_COMPONENTS', set()) ignored_app_component_prefixes = getattr( application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set()) for component_name in sorted(component_files): files = component_files[component_name] component_loc = sum(f[1] for f in files) if component_name not in WHITE_LIST and component_name not in ignored_app_components and all( not component_name.startswith(prefix) for prefix in ignored_app_component_prefixes): max_loc = max(component_loc, max_loc) if component_loc > THRESHOLD: raise Exception( '{} contains {} lines of code, extract component out!\n{}'. format(component_name, component_loc, '\n'.join(unicode(f) for f in files))) if THRESHOLD > GOAL and THRESHOLD - max_loc > 50: raise Exception('Threshold can be reduced to {} now', max_loc)
def update_dynamic_dependencies(): if not is_recording_dynamic_dependencies(): LOGGER.warn('cannot update dynamic dependencies because the recording is not started yet') return try: load_all_components() # import module will execute a lot record_dynamic_dependency_provider except Exception: pass
def update_dynamic_dependencies(): if not is_recording_dynamic_dependencies(): LOGGER.warn( 'cannot update dynamic dependencies because the recording is not started yet' ) return try: load_all_components( ) # import module will execute a lot record_dynamic_dependency_provider except Exception: pass
def check_correctness(): package_names = ['veil'] all_components = load_all_components( ) # load all so sys.modules contains module to be tested for component_name in all_components: package_names.append(component_name) test_package(*package_names)
def check_loc(): veil_component.load_all_components() component_files = {} for module_name, module in sys.modules.items(): component_name = veil_component.get_leaf_component(module_name) if component_name and hasattr(module, '__file__'): module_file = module.__file__.replace('.pyc', '.py') module_loc = get_loc(module_file) component_files.setdefault(component_name, []).append((module_file, module_loc)) max_loc = 0 application = get_application() ignored_app_components = getattr(application, 'LOC_CHECK_IGNORED_COMPONENTS', set()) ignored_app_component_prefixes = getattr(application, 'LOC_CHECK_IGNORED_COMPONENT_PREFIXES', set()) for component_name in sorted(component_files): files = component_files[component_name] component_loc = sum(f[1] for f in files) if component_name not in WHITE_LIST and component_name not in ignored_app_components and all( not component_name.startswith(prefix) for prefix in ignored_app_component_prefixes): max_loc = max(component_loc, max_loc) if component_loc > THRESHOLD: raise Exception('{} contains {} lines of code, extract component out!\n{}'.format( component_name, component_loc, '\n'.join(unicode(f) for f in files))) if THRESHOLD > GOAL and THRESHOLD - max_loc > 50: raise Exception('Threshold can be reduced to {} now', max_loc)
def execute_document_statement(statement_name, *args): if not get_executing_test(optional=True): load_all_components() set_up_fake_test() atexit.register(tear_down_fake_test) return contexts[-1](statement_name, args)
def check_correctness(): package_names = ['veil'] all_components = load_all_components() # load all so sys.modules contains module to be tested for component_name in all_components: package_names.append(component_name) test_package(*package_names)