Registry / testing / tag-expressions

tag-expressions

JSON →
library2.0.1pypypi✓ verified 83d ago

Tag Expressions is a Python library that provides an implementation for parsing and evaluating Cucumber Tag Expressions. It allows you to check if a set of tags matches a given boolean expression string. The current version is 2.0.1, with releases typically occurring for maintenance or minor feature additions, following a stable core API.

pip install tag-expressions
INSTALL
IMPORT
SIG · TAG-EXPRESSIONS
T
tag-expressions
testingpythonv2.0.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

evaluate
from tagexpressions import evaluate
from tag_expressions import evaluate
parse
from tagexpressions import parse
models
from tagexpressions import models

This quickstart demonstrates how to import and use the `evaluate` function with various boolean tag expressions and tag lists.

from tag_expressions import evaluate # Basic tag evaluation assert evaluate('tag1', ['tag1']) is True assert evaluate('tag1', ['tag2']) is False # AND operator assert evaluate('tag1 and tag2', ['tag1', 'tag2']) is True assert evaluate('tag1 and tag2', ['tag1']) is False # OR operator assert evaluate('tag1 or tag2', ['tag1']) is True assert evaluate('tag1 or tag2', ['tag2']) is True # NOT operator assert evaluate('not tag1', ['tag2']) is True assert evaluate('not tag1', ['tag1']) is False # Combined expression assert evaluate('(tag1 or tag2) and not tag3', ['tag1', 'tag4']) is True assert evaluate('(tag1 or tag2) and not tag3', ['tag2', 'tag4']) is True assert evaluate('(tag1 or tag2) and not tag3', ['tag1', 'tag3']) is False print("All tag expressions evaluated successfully!")
Debug
Known issues
breakingVersion 2.0.0 dropped support for Python 2.x. The library is now Python 3.8+ only.
fix
Ensure your project is running on Python 3.8 or newer. If you need Python 2 compatibility, you must use a version prior to 2.0.0 (e.g., `pip install 'tag-expressions<2.0.0'`).
affects: >=2.0.0
gotchaThe `evaluate` function expects the `tags` argument to be an iterable (e.g., a list or set) of strings, not a single string.
fix
Always pass a list or other iterable of tag strings, even if there's only one tag. For example, `evaluate('tag1', ['tag1'])` not `evaluate('tag1', 'tag1')`.
affects: all
gotchaThis library implements the *Cucumber* Tag Expressions grammar, which has specific syntax and operator precedence. It is not a general-purpose boolean expression parser.
fix
Refer to the Cucumber Tag Expressions documentation for the supported grammar and behavior to avoid unexpected evaluation results. Only `and`, `or`, `not`, and parentheses are supported.
affects: all
Upgrade
Version history
2.0.1latest on PyPI · released Nov 23, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
tag-expressions — pip install tag-expressions · libregistry