cucumber-tag-expressions provides a parser and evaluation logic for boolean tag expressions, commonly used in Cucumber and Behave for filtering scenarios. It is currently at version 9.1.0 and is actively maintained across multiple language implementations, with Python-specific updates occurring as needed.
pip install cucumber-tag-expressionsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse a tag expression string and then use the resulting evaluator function to check if a given set of tags matches the expression.
Upgrade Python environment to version 3.10 or higher. If unable to upgrade, use an older version of `cucumber-tag-expressions` (e.g., < 8.0.0).
For example, a Gherkin tag `@x(y)` should be expressed as `@x\(y\)` in the tag expression string. A tag `@x\y` should be `@x\\y`.
Refer to the official `cucumber-tag-expressions` documentation or the `behave` documentation for tag expression migration examples. Convert old-style comma-separated tags to `or` and multiple `--tags` arguments to `and`.
Install the library using pip: `pip install cucumber-tag-expressions`
Correct the syntax of the tag expression string. Ensure all parentheses are matched and operators (`and`, `or`, `not`) are used correctly. For example, `parse('(@wip or @bug) and not @slow')`.Update `behave` to a version that supports Tag-Expressions v2 (e.g., behave 1.2.7.dev0 or later), or use the older `behave` tag syntax. For `OR`, use `behave --tags @tag1,@tag2`. For `AND`, use `behave --tags @tag1 --tags @tag2`.