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.4.0.tar.gz (6.3 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.4.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_black-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 6622bce5af588697b4049342db8158438155e76c47b617b35596fe1465ab6310
MD5 6cf5fc9c5218046641c583f962ff4cd0
BLAKE2b-256 925ca2f02244f99656bbc8d6f9a7ca287adbf83a398a77594d236868eea14a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_black-0.4.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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 339c3bd111195853511c9484f31e82f17af0113e92c34fe1c1613ef6fc497ee9
MD5 152a5e51511de28f8e53601e7f2d9751
BLAKE2b-256 e34a194bc187453e1f898a7157939b06c599da251bc717df5b462fe97b1a9441

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