def before_scenario(context: Context, scenario: Scenario): """ In this function, we launch a container, install ubuntu-advantage-tools and then capture an image. This image is then reused by each scenario, reducing test execution time. """ reason = _should_skip_tags(context, scenario.effective_tags) if reason: scenario.skip(reason=reason) return filter_series = context.config.filter_series given_a_series_match = re.match( "a `(.*)` machine with ubuntu-advantage-tools installed", scenario.steps[0].name, ) if filter_series and given_a_series_match: series = given_a_series_match.group(1) if series and series not in filter_series: scenario.skip( reason=("Skipping scenario outline series `{series}`." " Cmdline provided @series tags: {cmdline_series}". format(series=series, cmdline_series=filter_series))) return if "uses.config.check_version" in scenario.effective_tags: # before_step doesn't execute early enough to modify the step # so we perform the version step surgery here for step in scenario.steps: if step.text: step.text = step.text.replace( "{UACLIENT_BEHAVE_CHECK_VERSION}", context.config.check_version, )
def before_scenario(context: Context, scenario: Scenario): """ In this function, we launch a container, install ubuntu-advantage-tools and then capture an image. This image is then reused by each scenario, reducing test execution time. """ reason = _should_skip_tags(context, scenario.effective_tags) if reason: scenario.skip(reason=reason)
def before_scenario(context: Context, scenario: Scenario): for tag in scenario.effective_tags: parts = tag.split(".") if parts[0] == "uses": val = context for attr in parts[1:]: val = getattr(val, attr, None) if val is None: scenario.skip( reason="Skipped because tag value was None: {}".format( tag))