Tag Expressions

2.0.1 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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!")

view raw JSON →