A pytest plugin for colorful print statements
Project description
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):
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
:
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
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.5.tar.gz
(90.9 kB
view details)
Built Distribution
File details
Details for the file pytest-crayons-0.0.5.tar.gz
.
File metadata
- Download URL: pytest-crayons-0.0.5.tar.gz
- Upload date:
- Size: 90.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 284f7794953bdb0e1a4964037a599ba3116d4e8274697244371d054fff67e87b |
|
MD5 | 468bd108aa09de4b915c5d3983eff526 |
|
BLAKE2b-256 | 6b80e42f81b96d884ef1f5052c474b3b9459578aa01b58b9d02d1631c0cf1ed2 |
File details
Details for the file pytest_crayons-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: pytest_crayons-0.0.5-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa20508392fb1316b91c6ce141eef90b7b035d1309c02c20580c4d1153eaeb75 |
|
MD5 | d58978932597a0381f838f013c767324 |
|
BLAKE2b-256 | d7e143a62fe3ae8d151e1e5865575b703f2f77c32dc32694941e2c2f5efbc717 |