{"id":2451,"library":"cucumber-tag-expressions","title":"Cucumber Tag Expressions","description":"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.","status":"active","version":"9.1.0","language":"en","source_language":"en","source_url":"https://github.com/cucumber/tag-expressions","tags":["cucumber","behave","tag-expressions","testing","bdd","gherkin"],"install":[{"cmd":"pip install cucumber-tag-expressions","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"note":"The primary entry point for parsing tag expressions.","symbol":"parse","correct":"from cucumber_tag_expressions import parse"}],"quickstart":{"code":"from cucumber_tag_expressions import parse\n\n# Define a tag expression\nexpression_string = \"@smoke and not @wip\"\n\n# Parse the expression to get an evaluator function\ntags_evaluator = parse(expression_string)\n\n# Define a set of tags to test against\nscenario_tags_1 = {\"@smoke\", \"@ui\"}\nscenario_tags_2 = {\"@smoke\", \"@feature\", \"@not_wip\"}\nscenario_tags_3 = {\"@smoke\", \"@wip\"}\n\n# Evaluate the expression against different sets of tags\nresult_1 = tags_evaluator(scenario_tags_1)\nresult_2 = tags_evaluator(scenario_tags_2)\nresult_3 = tags_evaluator(scenario_tags_3)\n\nprint(f\"Expression '{expression_string}' against {scenario_tags_1}: {result_1}\")\nprint(f\"Expression '{expression_string}' against {scenario_tags_2}: {result_2}\")\nprint(f\"Expression '{expression_string}' against {scenario_tags_3}: {result_3}\")\n\n# Expected output:\n# Expression '@smoke and not @wip' against {'@ui', '@smoke'}: True\n# Expression '@smoke and not @wip' against {'@feature', '@not_wip', '@smoke'}: True\n# Expression '@smoke and not @wip' against {'@wip', '@smoke'}: False","lang":"python","description":"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."},"warnings":[{"fix":"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).","message":"Version 8.0.0 dropped support for Python versions 2.x up to 3.9. Users must use Python 3.10 or newer.","severity":"breaking","affected_versions":"8.0.0 and later"},{"fix":"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`.","message":"When constructing tag expressions, remember to escape reserved characters (parentheses '()', backslash '\\', or whitespace) within a tag name using a backslash.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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`.","message":"This library implements the current Cucumber Tag Expression syntax. Users migrating from older Cucumber versions (e.g., those using `--tags ~@dev` or `--tags @foo,@bar`) should convert their expressions to the new boolean logic format (e.g., `not @dev` or `@foo or @bar`).","severity":"gotcha","affected_versions":"All versions (for users migrating from old Cucumber CLI tag syntax)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}