Exemplo n.º 1
0
def collect_setup_files(context):
    """
    Searches feature files in 'setup' directory for any configured setup features
    and adds them to the context of the current run. This is done before_all so
    that the setup features are available during the run.
    """
    setup_files = os.path.join(context.config.base_dir, settings.SETUP_DIR)
    logger.info(f'Parsing setup files from the {setup_files} directory.')

    feature_locations = collect_feature_locations([setup_files])
    all_features = parse_features(feature_locations)
    context_setup = {}
    for feature in all_features:
        tag_name = None
        for tag in feature.tags:
            if tag.startswith('configure.'):
                tag_name = tag.replace('configure.', '')
                break
        if not tag_name:
            # This was not a configuration, so skip the feature
            continue
        logger.info(
            f'Setting Context Setup {tag_name} from {feature.location}.')
        setup = {'setup': [], 'teardown': []}
        for scenario in feature.scenarios:
            if any(tag == 'teardown' for tag in scenario.tags):
                logger.info(f'Setting teardown from {scenario.location}.')
                setup['teardown'].append(scenario)
            elif any(tag == 'setup' for tag in scenario.tags):
                logger.info(f'Setting setup from {scenario.location}.')
                setup['setup'].append(scenario)
        context_setup[tag_name] = setup
    context.context_setup = context_setup
Exemplo n.º 2
0
 def feature_locations(self):
     return collect_feature_locations(self.config.paths)
Exemplo n.º 3
0
 def feature_locations(self):
     return collect_feature_locations(self.config.paths)