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.6.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_black-0.6.0.tar.gz
  • Upload date:
  • Size: 6.3 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.6.0.tar.gz
Algorithm Hash digest
SHA256 ecb77455f379805cb4bd8f45a813a3754c3bbee3199adf1b3665c0dfd086b511
MD5 7acfa0e0aaeed6f7bc164164f8594790
BLAKE2b-256 1120b0a2b3e1c09b61831d5c702d9e0579fc935e6a2527ce66dec1ba580a722b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_black-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7eb747f54b6c997497b5cbc66a988be114b92016dbfa66d210d1d1f9f6b2dc76
MD5 990a5c23eb3571ff1733f8130c32c658
BLAKE2b-256 da0f71303b06ef91f6e9447efb14cc37755b2224ff7109422fef125cb357d7d3

See more details on using hashes here.

Supported by

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