@then('the tag expression selects model elements with')
def step_given_named_model_elements_with_tags(context):
    """
    .. code-block:: gherkin

        Then the tag expression select model elements with:
            | tag expression | selected?    |
            |  @foo          | S1, S3       |
            | -@foo          | S0, S2, S3   |
    """
    assert context.model_elements, "REQUIRE: context attribute"
    assert context.table, "REQUIRE: context.table"
    context.table.require_columns(["tag expression", "selected?"])

    for row_index, row in enumerate(context.table.rows):
        tag_expression_text = row["tag expression"]
        tag_expression = convert_tag_expression(tag_expression_text)
        expected_selected_names = convert_comma_list(row["selected?"])

        actual_selected = []
        for model_element in context.model_elements:
            if tag_expression.check(model_element.tags):
                actual_selected.append(model_element.name)

        assert_that(actual_selected, equal_to(expected_selected_names),
            "tag_expression=%s (row=%s)" % (tag_expression_text, row_index))
dataset/ETHPy150Open behave/behave/features/steps/behave_tag_expression_steps.py/step_given_named_model_elements_with_tags/original