skillfed

pytest-black

A pytest plugin to enable format checking with black

pytest-black v0.6.0 157.2K downloads/30d#10,762 on PyPI0
Permissive license MIT DORMANT released

What it is and what it does

pytest-black is a pytest plugin that integrates black's code formatting checks into your test suite. When you run pytest with the --black flag, it scans your code and reports any formatting violations that black would fix, displaying a diff of suggested changes. The plugin does not modify your code—it only reports violations, leaving the decision to apply changes to you or your CI pipeline.

The plugin relies on pytest, black, and toml as runtime dependencies. It reads black configuration from pyproject.toml if present, allowing you to customize formatting rules per project. This makes it useful for enforcing consistent code style as part of automated testing rather than as a standalone formatter.

Use it for:

  • Enforce code formatting standards in CI/CD pipelines by failing tests when black violations are detected.
  • Catch formatting inconsistencies during local development before pushing code to version control.
  • Integrate style checking into existing pytest workflows without adding separate linting steps.
  • Report formatting diffs to developers during test runs so they can see exactly what black would change.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that runs black format checks on your code during test execution, reporting formatting violations without applying changes automatically.

Yes, if you already use pytest and black and want formatting checks as part of your test suite. The low install friction and permissive license make it straightforward to add. However, the dormant maintenance status (last commit 2024-12-23, zero repository stars) and old Python support floor (>=3.5) suggest limited ongoing development; verify compatibility with your current black version before relying on it in production CI/CD.

Install

pytest-black on PyPI

pip

pip install pytest-black

uv

uv add pytest-black

poetry

poetry add pytest-black

Installing pytest-black

Before you install

Low friction install with three straightforward dependencies (pytest, black, toml). Maintenance is dormant—last release was 2024-12-15 but no commits since 2024-12-23, and the repository shows zero stars, suggesting limited active community engagement.

License in practice

MIT license (permissive) means you can use, modify, and distribute the package freely with minimal restrictions, typical for open-source development tools.

Quickstart

pip install pytest-black

# In your test run:
pytest --black

# Outputs formatting diffs without applying changes

Requires black 19.3b0 or later; requires pytest and toml as runtime dependencies.

Verify before relying

  • Whether the plugin works correctly with recent black versions beyond 19.3b0.
  • Current state of compatibility with modern Python 3.x versions (requires_python is >=3.5, which is quite old).
  • Whether dormant maintenance status affects reliability in active CI/CD pipelines.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies 3 — pytest, black, toml
Maintenance dormant — 607 days since the last release
Last repo commit
First released
Downloads 157,185/month — #10,762 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_black-0.6.0-py3-none-any.whl

Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Software Development :: Testing

Tags

pytest black format checkingcode style validation pytestblack integration testingformat linting in testspytest formatting plugin
pytest-plugincode-formattingci-integration

More Testing packages