pytest-crayons
A pytest plugin for colorful print statements.
Installation
pip install pytest-crayons
Usage
- Include a color fixture in the param list of a test.
- 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
-sor--capture=no - or you wrap the statement in a
with capsys.disabled():block.
For our examples, we'll use -s:
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")
This was included in a talk for PyCascades 2023
- Conference talk page : Sharing is Caring - Sharing pytest Fixtures
Release files for pytest-crayons 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_crayons-0.0.9.tar.gz | 90.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_crayons-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 95.1 kB
Release files / pytest_crayons-0.0.9.tar.gz
| Download URL | pytest_crayons-0.0.9.tar.gz |
|---|---|
| Size | 90.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f508afce82a71fa59d68758a70c2c703c30d01211926d29e00fa219797437cf
|
|
BLAKE2b-256 checksum How to use checksums |
79999bd978f081053d89b21571be49dc09635aa57dc5d00568895ed7d4db1c17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2025.
Transparency logRelease files / pytest_crayons-0.0.9-py3-none-any.whl
| Download URL | pytest_crayons-0.0.9-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29acf623c1155799cff226de86a05a66aeff559d15a80bfe56b69921afd6d8b6
|
|
BLAKE2b-256 checksum How to use checksums |
caa6b8150650f331672ddb61b6bfac2347faa75dbf26349fc003f76aee793b48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2025.
Transparency log