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.6.tar.gz
(93.2 kB
view details)
Built Distribution
File details
Details for the file pytest-crayons-0.0.6.tar.gz
.
File metadata
- Download URL: pytest-crayons-0.0.6.tar.gz
- Upload date:
- Size: 93.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19e17375ad0bb266024e9cbc2e5c228fde40d1b8d050ed29ef8c1afd7344b71 |
|
MD5 | 4aeaea2f2c245ba9f3981e1f9f1d5b81 |
|
BLAKE2b-256 | 7d6246e5728a06ee84c2a91633fb06e9541085039ef1ed2216319d2781799740 |
File details
Details for the file pytest_crayons-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: pytest_crayons-0.0.6-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ca75948c2765a82d6eebf2cd79e8d69da06d0c592decd27b0fbbce9bd5cd1c6 |
|
MD5 | a7c4361bdc6d3691a1c6df1b8ac098c2 |
|
BLAKE2b-256 | 5b522425242e62fb88f730b04d5bd077398d12b530b965fbd69b4ad92fe4e3aa |