Data management for Behave — typed tables, diff, dynamic examples, fixtures, secrets
Project description
behave-data
Data management for Behave — typed tables, diffs, dynamic examples, fixtures, and secrets with zero boilerplate.
Built on top of behave-tables.
Full documentation: mathiaspaulenko.github.io/behave-data
Quick links
Why?
Behave data tables are strings. Everything is "42", "true", "". You write boilerplate in environment.py to convert types, handle nulls, load examples, and manage test data.
behave-data fixes this:
| Without behave-data | With behave-data |
|---|---|
row["age"] → "42" (string) |
row["age"] → 42 (int) |
Empty cell → "" |
Empty cell → None |
Hardcoded Examples in .feature |
Load from CSV, JSON, YAML, Excel, SQL, HTTP |
Manual before_all / after_scenario |
@needs_data, @with_fixture, @cleanup_after tags |
| Secrets in feature files | env:VAR, file:path, secret:name with masking |
Features
- Typed Tables —
name:str,age:int,active:bool,price:float,created:datewith automatic conversion - Null Resolution — Empty cells become
None, configurable markers ("","null","N/A"), per-column overrides - Table Diff — Cucumber-style diff output with row/column mismatch detection
- Raw Tables — Access tables without header assumption, vertical tables, transposed data
- Dynamic Examples —
@load_examples:csv:users.csvreplaces static Examples blocks - Fixtures — Reusable data recipes with nesting (
ref:other) and parametrization - Builders — Construct test data with derived fields and overrides
- Secrets —
env:,file:,secret:placeholders with Vault and AWS backends, automatic masking - Declarative Tags —
@needs_data,@with_fixture,@cleanup_afterfor zero-boilerplate setup/teardown
Install
pip install behave-data
Optional extras:
| Extra | Packages | Use case |
|---|---|---|
yaml |
PyYAML | YAML loader |
excel |
openpyxl | Excel loader |
sql |
SQLAlchemy | SQL loader |
http |
requests | HTTP loader |
vault |
hvac | HashiCorp Vault secrets |
aws |
boto3 | AWS Secrets Manager |
all |
all above | All optional loaders and backends |
dev |
pytest, ruff, mypy, build | Development |
pip install behave-data[yaml,excel] # multiple extras
pip install behave-data[dev] # contribute
Quickstart
# features/environment.py
from behave_data import (
setup_data,
before_feature_hook,
before_scenario_hook,
before_step_hook,
after_scenario_hook,
)
def before_all(context):
setup_data(context)
def before_feature(context, feature):
before_feature_hook(context, feature)
def before_scenario(context, scenario):
before_scenario_hook(context, scenario)
def before_step(context, step):
before_step_hook(context, step)
def after_scenario(context, scenario):
after_scenario_hook(context, scenario)
# features/login.feature
@load_examples:csv:features/data/users.csv
Scenario Outline: User login
Given a user with name "<name>" and email "<email>"
When they log in
Then they see the dashboard
Examples:
# features/steps/login.py
from behave_data import typed_wrap, diff
@then("the users should match")
def step_match(context):
table = typed_wrap(context.table)
for row in table.typed_dicts():
assert isinstance(row["age"], int) # typed, not string
assert row["city"] is None or row["city"] # None for empty cells
That's it. Type annotations in headers, nulls resolved, examples from external files, tags for setup/teardown — all automatic.
Documentation
| Section | Link |
|---|---|
| Quickstart | Quickstart |
| Typed Tables | Typed Tables |
| Null Handling | Null Handling |
| Table Diff | Diff |
| Dynamic Examples | Dynamic Examples |
| Fixtures | Fixtures |
| Builders | Builders |
| Secrets | Secrets |
| Declarative Tags | Tags |
| Hooks | Hooks |
| Configuration | Configuration |
| Cookbook | Cookbook |
| Troubleshooting | Troubleshooting |
| API Reference | API |
| Migration Guide | Migration |
| Changelog | Changelog |
Migration from behave-tables
behave-data depends on behave-tables and extends it:
pip install behave-data—behave-tablescomes as a dependency- Use
typed_wrap()instead ofwrap()for typed column conversion - Add
setup_data(context)inbefore_all()to enable hooks, fixtures, builders, and secrets
All behave-tables APIs (as_dicts, as_models, transpose, to_csv, to_json, find_row, select, etc.) remain available via the re-exported TableWrapper and wrap().
See the Migration Guide for details.
Configuration
# behave_data.yml
null_markers: ["", "null", "None", "N/A"]
null_markers_by_column:
age: ["", "unknown"]
secret_backend: env
secret_path: secrets/
load_base_dir: features/data/
See Configuration for all options.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for setup, development commands, and the release checklist.
For security issues, see SECURITY.md.
Acknowledgements
- Built on behave-tables for table manipulation.
- Inspired by the Behave community's need for first-class data handling in Gherkin scenarios.
License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file behave_data-1.0.1.tar.gz.
File metadata
- Download URL: behave_data-1.0.1.tar.gz
- Upload date:
- Size: 78.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f0773477ff9ff796668be110cdd0d23cb479bb5f3efe44ed441d72e5646fa62
|
|
| MD5 |
9c4cb88efa4dde7d769bf13cae0ece6f
|
|
| BLAKE2b-256 |
c74ccb9eee3d7c4e2837948abe877eab0a20a1eb7e16804be257b9d67f72c961
|
Provenance
The following attestation bundles were made for behave_data-1.0.1.tar.gz:
Publisher:
release.yml on MathiasPaulenko/behave-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_data-1.0.1.tar.gz -
Subject digest:
9f0773477ff9ff796668be110cdd0d23cb479bb5f3efe44ed441d72e5646fa62 - Sigstore transparency entry: 2195717355
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-data@7e382488bd311b66edae9d11686d8273eab16d0d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7e382488bd311b66edae9d11686d8273eab16d0d -
Trigger Event:
push
-
Statement type:
File details
Details for the file behave_data-1.0.1-py3-none-any.whl.
File metadata
- Download URL: behave_data-1.0.1-py3-none-any.whl
- Upload date:
- Size: 37.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57e5746b35ce4cb2838b50a3e2d2587b95acff4870e8e528ca83641661d2cd36
|
|
| MD5 |
285663774f273bfc27d2892e55c5ee3e
|
|
| BLAKE2b-256 |
94a1ebce8f57a3aca40b2bba10e1ff274c6e1e0d588929fc2ab6cf8ffb069b87
|
Provenance
The following attestation bundles were made for behave_data-1.0.1-py3-none-any.whl:
Publisher:
release.yml on MathiasPaulenko/behave-data
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_data-1.0.1-py3-none-any.whl -
Subject digest:
57e5746b35ce4cb2838b50a3e2d2587b95acff4870e8e528ca83641661d2cd36 - Sigstore transparency entry: 2195717364
- Sigstore integration time:
-
Permalink:
MathiasPaulenko/behave-data@7e382488bd311b66edae9d11686d8273eab16d0d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/MathiasPaulenko
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7e382488bd311b66edae9d11686d8273eab16d0d -
Trigger Event:
push
-
Statement type: