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-9.1.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-9.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cucumber_tag_expressions-9.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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-9.1.0.tar.gz
Algorithm Hash digest
SHA256 d960383d5885300ebcbcb14e41657946fde2a59d5c0f485eb291bc6a0e228acc
MD5 ffd0fd57d51d1c4a8c9da6faa32cc5b2
BLAKE2b-256 b1e0de0b292a533846def28a4373a00c883ffa5ed986ca79f0284bd69a6297b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cucumber_tag_expressions-9.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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-9.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cca145d677a942c1877e5a2cf13da8c6ec99260988877c817efd284d8455bb56
MD5 50766d1223b878bdbf0f5abeb2a5ebfc
BLAKE2b-256 6bcf8e8d034f7d55fceb2e4765bf9fab5da6d6a09204cd09de7bb5054f242cd0

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