tdda
Test-driven data analysis: command-line tools and Python APIs for data validation, testing analytical pipelines, automatic test generation and more.
What it is and what it does
tdda is a Python framework for test-driven data analysis—a methodology where you write tests for data pipelines before or alongside the analysis code itself. It extends unittest and pytest with reference testing (comparing outputs to stored baselines), automatic test generation from command-line scripts, and constraint-based validation. The package also includes utilities for discovering data constraints from existing DataFrames or files, inferring regular expressions from string columns, diffing data across formats, and documenting CSV schemas in portable metadata files.
The core use case is validating analytical pipelines: you define what "correct" data looks like (via constraints or reference outputs), then verify that new data conforms to those rules. It integrates with pandas, polars, and parquet, and can work with relational databases when optional drivers are installed. The reference testing mode is particularly useful for regression detection—if your pipeline's output changes unexpectedly, the test catches it immediately.
Use it for:
- Write reference tests for data transformation pipelines to catch regressions when code or data changes.
- Automatically generate baseline tests from existing command-line scripts or programs without manual test writing.
- Discover and enforce data quality constraints (e.g., non-null columns, value ranges) on incoming datasets.
- Infer regex patterns from sample string data to validate or extract structured text fields.
- Compare two versions of a dataset (Parquet or CSV) and report row-level and column-level differences visually.
- Document CSV and flat-file formats in portable metadata files compatible with CSVW and Frictionless standards.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
tdda provides test-driven data analysis tools: reference testing for data pipelines, automatic test generation, constraint discovery and validation, regex inference, data diffing, and metadata documentation for CSV/flat files.
Yes, if you work with data pipelines and want automated validation. tdda fills a real gap between unit testing and data quality tools—reference testing catches regressions cheaply, and constraint discovery is faster than manual validation rules. Active maintenance, permissive license, and no security vulnerabilities. The 12-package dependency footprint is substantial but standard for data work; install it in projects where pandas or polars are already present.
Install
tdda on PyPI
pip
pip install tddauv
uv add tddapoetry
poetry add tddaInstalling tdda
Before you install
Low friction: pure Python wheel, active maintenance (last commit 2026-07-13), and a substantial dependency stack (numpy, pandas, pyarrow, pyyaml, pytest, chardet, rich, regex, tomli_w, tomli, polars, requests) that will be installed together. Suitable for projects already using data science libraries.
License in practice
MIT license is permissive; you can use, modify, and distribute tdda freely in commercial and private projects with minimal restrictions.
Quickstart
pip install tdda
from tdda.referencetest import ReferenceTestCase
import unittest
class MyDataTest(ReferenceTestCase):
def test_pipeline(self):
result = my_analysis_function()
self.assertDataFrameCorrect(result, 'expected.csv')
Requires Python >=3.8; optional database support (PostgreSQL, MySQL/MariaDB, MongoDB) requires separate driver installation.
Verify before relying
- Whether constraint discovery works on databases other than those listed in optional setup.
- Performance characteristics when working with very large Parquet files or DataFrames.
- Compatibility of CSVW and Frictionless metadata conversion with all format variants.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 12 — numpy, pandas, pyarrow, pyyaml, pytest, chardet, rich, regex, tomli_w, tomli, polars, requests |
| Maintenance | actively maintained — 32 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 293,247/month — #7,955 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tdda-3.3.0-py3-none-any.whl
Keywords: tdda, constraint, referencetest, rexpy
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pydeequPyDeequ is a Python API for Apache Spark-based…
permissive · top 5,000 on PyPI
pandas-schemaValidates pandas DataFrames against…
permissive · top 15,000 on PyPI
dtaleD-Tale is a Flask-backed web interface for…
copyleft · top 15,000 on PyPI
duckdbDuckDB is an in-process SQL database engine…
permissive · top 1,000 on PyPI
pyddqPyDDQ is a Python API for running data quality…
permissive · top 15,000 on PyPI
collate-data-diffCompares rows across two SQL databases or…
permissive · top 5,000 on PyPI
tdd-guard-pytestA pytest plugin that captures test results and…
permissive · top 15,000 on PyPI
cucumber-expressionsCucumber Expressions provides a simpler, more…
permissive · top 5,000 on PyPI
iregexp-checkValidates regular expressions against RFC 9485…
permissive · top 15,000 on PyPI
pytest-htmlGenerates HTML reports for pytest test results,…
copyleft · top 1,000 on PyPI