{"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":"python","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,"search_vec":"'9.1.0':32 'across':37 'activ':35 'bdd':55 'behav':23,50 'boolean':15 'common':18 'cucumb':1,5,21,49 'cucumber-tag-express':4 'current':29 'evalu':12 'express':3,7,17,53 'filter':25 'gherkin':56 'implement':40 'languag':39 'logic':13 'maintain':36 'multipl':38 'need':48 'occur':46 'parser':10 'provid':8 'python':43 'python-specif':42 'scenario':26 'specif':44 'tag':2,6,16,52 'tag-express':51 'test':54 'updat':45 'use':19 'version':31","created_at":"2026-04-11T01:28:41.887460+00:00","updated_at":"2026-04-16T04:25:02.328200+00:00","problems":[{"fix":"Install the library using pip: `pip install cucumber-tag-expressions`","cause":"The `cucumber-tag-expressions` library has not been installed or is not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'cucumber_tag_expressions'"},{"fix":"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')`.","cause":"The provided tag expression string contains a syntax error, such as unmatched parentheses, illegal escape characters, or incorrect operator usage.","error":"cucumber_tag_expressions.parser.TagExpressionParserException: Tag expression \"invalid (\" could not be parsed because of syntax error: Unmatched (`"},{"fix":"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`.","cause":"Older versions of `behave` (e.g., 1.2.6) do not natively support the advanced boolean tag expression syntax (like `and`, `or`) that `cucumber-tag-expressions` provides, even if the library is installed. They use a comma-separated syntax for OR and separate `--tags` options for AND.","error":"behave --tags '@tag1 and @tag2' does not work"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"11.0.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cucumber/tag-expressions","docs":null,"changelog":"https://github.com/cucumber/tag-expressions/releases","pypi":"https://pypi.org/project/cucumber-tag-expressions/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}