Skip to main content

A pytest plugin to enable format checking with black

Project description

pytest-black

A pytest plugin to enable format checking with black.

Requirements

There is a minimum requirement of black 19.3b0 or later.

Installation

$ pip install pytest-black

Usage

To run pytest with formatting checks provided by black:

$ pytest --black

The plugin will output a diff of suggested formatting changes (if any exist). Changes will not be applied automatically.

Configuration

You can override default black configuration options by placing a pyproject.toml file in your project directory. See example configuration here.

Python package management

For poetry to work correctly, include this in your pyproject.toml configuration file:

[tool.poetry.dev-dependencies]
...
black = { version = "*", allow-prereleases = true }
...

This is necessary because at the time of writing all the black releases in PyPI have been tagged as pre-releases (beta code), which breaks poetry's dependency resolution.

Testing

To run the tests against a selection of Python interpreters:

$ tox

To run against a specific interpreter (e.g. Python 3.6):

$ tox -e py36

The tox.ini file in the root of this repository is used to configure the test environment.

License

Distributed under the terms of the MIT license, pytest-black is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

pytest_black-0.5.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_black-0.5.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest_black-0.5.0.tar.gz.

File metadata

  • Download URL: pytest_black-0.5.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for pytest_black-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b5e901d62e4aedf6b053e7879c052a9f6b72df6739b9e7ae216b98b468f50ffd
MD5 43b3c485f5273bd44adf56aaab1c0451
BLAKE2b-256 437f61ed8066da38f50814accfa493cf3e4edd8a6e5355f22c1c3524a5d7f26d

See more details on using hashes here.

File details

Details for the file pytest_black-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_black-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for pytest_black-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3e089494dfc9af94488e0e6de78c9cf85ac2b22a8a30fc6915eed645b0594e7
MD5 91b153d7b15efd44895e9e295feef20b
BLAKE2b-256 faba097b7882063d006a322e9c58cccc9f114ea1806568beb8744a6996fe5f67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page