Skip to main content

behave-data

PyPI Python Tests Docs Coverage License

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


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 Tablesname:str, age:int, active:bool, price:float, created:date with 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.csv replaces static Examples blocks
  • Fixtures — Reusable data recipes with nesting (ref:other) and parametrization
  • Builders — Construct test data with derived fields and overrides
  • Secretsenv:, file:, secret: placeholders with Vault and AWS backends, automatic masking
  • Declarative Tags@needs_data, @with_fixture, @cleanup_after for 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:

  1. pip install behave-databehave-tables comes as a dependency
  2. Use typed_wrap() instead of wrap() for typed column conversion
  3. Add setup_data(context) in before_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

MIT

Release files for behave-data 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behave-data 1.0.2
File Size Uploaded
behave_data-1.0.2.tar.gz 79.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for behave-data 1.0.2
File Interpreter ABI Platform
behave_data-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 116.6 kB

Release files / behave_data-1.0.2.tar.gz

Download URL behave_data-1.0.2.tar.gz
Size 79.0 kB
Tags Source
SHA-256 checksum
How to use checksums
531bc160b08cff42631c1990e6e6fc443fb6b06615a9ae219c3bb82091f0035c
BLAKE2b-256 checksum
How to use checksums
f66e63816467c1ca7616c76b95612073a50ecda8c9cb93fb0fa78d3558288bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release files / behave_data-1.0.2-py3-none-any.whl

Download URL behave_data-1.0.2-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d942db9aeba7da5fe36eef23b8b3c06473834efa36655d427ef3deff15b9149
BLAKE2b-256 checksum
How to use checksums
51f51c4907a363fbf2227e70202c8d3b61c8940e0ef2a8f8ae792b5e8e17761d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page