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_something(blue):
    ... # some code
    blue("a print statement, that shows up blue")
    ... # more test code

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 in red")
    green("this should be in green")
    yellow("this should be in yellow")
    blue("this should be in blue")
    magenta("this should be in magenta")
    cyan("this should be in cyan")

output of test_colors

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.3.tar.gz (62.3 kB view details)

Uploaded Source

Built Distribution

pytest_crayons-0.0.3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest-crayons-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a4c49fd214c08044dbc5440782da3b24d20a49466b9894bd86d23c612dce663e
MD5 2fdd1f760ae66064fbaf83967f63f408
BLAKE2b-256 344cda20bbb391b97ba12c83ab0d21a746ed22e0ecfc27c4f19d9cbbc1d28b49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_crayons-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 771b7dd8df727e595a6ca871915bc956928b2019c5c6d2643af42ba6d259a135
MD5 5f2dc625805b2e8928fd3cfe9d349baf
BLAKE2b-256 0d891276fcb770ffa9be76f8f50a48e80fa88b402798d039308f28eb0b19e0a5

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