Skip to main content

pytest-crayons

A pytest plugin for colorful print statements.

Installation

pip install pytest-crayons

Usage

  1. Include a color fixture in the param list of a test.
  2. Then use it instead of print.
def test_magenta(magenta):
    magenta("this should be magenta")

Just like normal print statements, you only see the output if:

  • There's an failure in the test.
  • or you pass in -s or --capture=no
  • or you wrap the statement in a with capsys.disabled(): block.

For our examples, we'll use -s:

output of test_something

Available colors

  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan

Example with all colors:

def test_colors(red, green, yellow, blue, magenta, cyan):
    print("") # for the newline
    red("this should be red")
    green("this should be green")
    yellow("this should be yellow")
    blue("this should be blue")
    magenta("this should be magenta")
    cyan("this should be cyan")

output of test_colors

This was included in a talk for PyCascades 2023

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_crayons-0.0.9.tar.gz (90.9 kB view details)

Uploaded Source

Built Distribution

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

pytest_crayons-0.0.9-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_crayons-0.0.9.tar.gz.

File metadata

  • Download URL: pytest_crayons-0.0.9.tar.gz
  • Upload date:
  • Size: 90.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_crayons-0.0.9.tar.gz
Algorithm Hash digest
SHA256 2f508afce82a71fa59d68758a70c2c703c30d01211926d29e00fa219797437cf
MD5 3cc2e35ccf12fa4a7216f321f54872bf
BLAKE2b-256 79999bd978f081053d89b21571be49dc09635aa57dc5d00568895ed7d4db1c17

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_crayons-0.0.9.tar.gz:

Publisher: pypi-package.yml on okken/pytest-crayons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_crayons-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: pytest_crayons-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_crayons-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 29acf623c1155799cff226de86a05a66aeff559d15a80bfe56b69921afd6d8b6
MD5 28b899bc83c8615b79012a7fd677fe10
BLAKE2b-256 caa6b8150650f331672ddb61b6bfac2347faa75dbf26349fc003f76aee793b48

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_crayons-0.0.9-py3-none-any.whl:

Publisher: pypi-package.yml on okken/pytest-crayons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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