Provides a tag-expression parser and evaluation logic for cucumber/behave
Project Links
Meta
Author: Jens Engel
Requires Python: >=3.10
Classifiers
Development Status
- 5 - Production/Stable
Environment
- Console
Intended Audience
- Developers
Operating System
- OS Independent
Programming Language
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Topic
- Software Development :: Testing
- Software Development :: Libraries :: Python Modules
Cucumber Tag Expressions
Readable boolean expressions to select features and scenarios marked with tags in Gherkin
# -- 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
Oct 14, 2025
8.0.0
Oct 03, 2025
7.0.0
May 25, 2025
6.2.0
Jan 29, 2025
6.1.2
Oct 28, 2024
6.1.1
Jan 10, 2024
6.1.0
Jan 06, 2024
6.0.0
Jan 06, 2024
5.0.6
Jan 06, 2024
5.0.5
Jan 06, 2024
5.0.4
Jan 06, 2024
5.0.3
Jan 06, 2024
5.0.2
Jan 06, 2024
5.0.1
Jan 06, 2024
5.0.0
Oct 08, 2021
4.1.0
Sep 13, 2021
4.0.2
Sep 02, 2021
4.0.0
Mar 31, 2021
3.0.1
Jun 11, 2020
3.0.0
Jan 10, 2020
2.0.4
Dec 11, 2019
2.0.3
Jul 06, 2019
1.1.2
Oct 21, 2018
1.1.1
May 05, 2018
1.0.2
Wheel compatibility matrix
Files in release
No dependencies