Skip to main content

A pytest plugin for colorful print statements

Project description


A pytest plugin for colorful print statements.


pip install pytest-crayons


  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.7.tar.gz (93.3 kB view hashes)

Uploaded Source

Built Distribution

pytest_crayons-0.0.7-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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