Skip to main content

A pytest plugin for colorful print statements

Project description

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):
    blue("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

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-crayons-0.0.4.tar.gz (90.9 kB view details)

Uploaded Source

Built Distribution

pytest_crayons-0.0.4-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-crayons-0.0.4.tar.gz.

File metadata

  • Download URL: pytest-crayons-0.0.4.tar.gz
  • Upload date:
  • Size: 90.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for pytest-crayons-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d98bd32d2e1c7d8969ee120cca95b0c391539e3a683de63af069f541765828d4
MD5 340875a5fd324c84daa96f291f8b27f2
BLAKE2b-256 dfd39c25a4b2e44c4f6b63b8810f0861f9ee18536c076c5374be9f92d9c94bcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_crayons-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 33098ae546ae156ef7709c867b405424bb69eba12d0bfa53b2ad044e483137e6
MD5 32b5b8c27b13f4904b96c2e32df18f12
BLAKE2b-256 a6c9b671274e38fc1c24925ecd78c20c31470ba616f8a8a3faeb19a1d423b1c4

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page