Skip to main content

Provides a tag-expression parser and evaluation logic for cucumber/behave

Project description

Cucumber logo
Cucumber Tag Expressions

Readable boolean expressions to select features and scenarios marked with tags in Gherkin

npm build backers sponsors build

# -- SIMPLE TAG-EXPRESSION EXAMPLES:
@a and @b
@a or @b
not @a

# -- MORE TAG-EXPRESSION EXAMPLES:
@a and not @b
(@a or @b) and not @c

Getting Started

Cucumber Tag Expressions is available as cucumber-tag-expressions on PyPI.

pip install cucumber-tag-expressions

Parse tag expressions and evaluate them against a set of tags.

>>> from cucumber_tag_expressions import parse

# Tagged with @fast
>>> fast = parse("@fast")
>>> fast({"@fast", "@wip"})
True
>>> fast({"@performance", "@slow"})
False

# Tagged with @wip and not @slow
>>> wip_not_slow = parse("@wip and not @slow")
>>> wip_not_slow({"@wip", "@home"})
True
>>> wip_not_slow({"wet", "warm", "raining"})
False

# Tagged with both `@fast` and `@integration`
>>> fast_integration = parse("@integration and @fast")
>>> fast_integration({"@integration", "@fast", "@other"})
True
>>> fast_integration({"@system", "@fast"})
False

# Tagged with either @login or @registration
>>> auth_pages = parse("@login or @registration")
>>> auth_pages({"@account", "@login"})
True
>>> auth_pages({"@admin", "@account"})
False

Test Runner Usage

A gherkin test runner (such as behave) uses tag expressions to select scenarios to run.

# -- TAG-EXPRESSION: @one and @two
# EXPECTED: Selects and runs scenario "Three".
$ my_cucumber_test_runner --tags="@one and @two" features/example.feature
...

# -- TAG-EXPRESSION: @one or @two
# EXPECTED: Selects and runs scenarios "One", "Two" and "Three".
$ my_cucumber_test_runner --tags="@one or @two" features/example.feature
...

Such as using the following feature file.

# -- FILE: features/example.feature
Feature: Tag expressions example

  @one
  Scenario: One
    Given a step passes

  @two
  Scenario: Two
    Given another step passes

  @one @two
  Scenario: Three
    Given some step passes

  Scenario: Four
    Given another step passes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cucumber_tag_expressions-11.0.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cucumber_tag_expressions-11.0.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file cucumber_tag_expressions-11.0.0.tar.gz.

File metadata

  • Download URL: cucumber_tag_expressions-11.0.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cucumber_tag_expressions-11.0.0.tar.gz
Algorithm Hash digest
SHA256 9739a7b3e04b3ee9f77748d2b48dc9e7ff41b041ed6b651283cfec022f0e6d0b
MD5 5253aceb1dafd19ce427d195058364b5
BLAKE2b-256 019869e82d5bfaebde03b205c6722e4ebe52940aad26a3768f3c3d28b1e391f3

See more details on using hashes here.

File details

Details for the file cucumber_tag_expressions-11.0.0-py3-none-any.whl.

File metadata

  • Download URL: cucumber_tag_expressions-11.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cucumber_tag_expressions-11.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86ce0647bed1e52d6a634649c31758faa22821531541848f221b1f6c4f75c9f7
MD5 5c743dd507070accc1651487efb8e276
BLAKE2b-256 ed34fbd46adb089ec277e9b7da3db479976c228c28407dce15e34554478c8ba9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page