一个用于彩色打印语句的pytest插件
项目描述
pytest-crayons
一个用于彩色打印语句的pytest插件。
安装
pip install pytest-crayons
使用
- 在测试的参数列表中包含一个颜色设置。
- 然后用它来代替
print
。
def test_magenta(magenta):
blue("this should be magenta")
就像正常的打印语句一样,只有在以下情况下你才能看到输出:
- 测试中存在失败。
- 或者你传递了
-s
或--capture=no
- 或者你用
with capsys.disabled():
块包裹语句。
在我们的例子中,我们将使用 -s
可用颜色
- 红色
- 绿色
- 黄色
- 蓝色
- 品红色
- 青色
所有颜色的示例
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")
这被包含在PyCascades 2023的演讲中
- 会议演讲页面:分享即关爱 - 分享pytest fixture
项目详情
关闭
pytest-crayons-0.0.7.tar.gz 的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | c1f1c13c00a4b71005f67ae6605c6f44019c961372f78e622bcfbe8a7229ed9c |
|
MD5 | d8d01df51387a4916186948102b3c167 |
|
BLAKE2b-256 | f87bf31ff22a5f5d066f57cc055ac282069e87ffe011d1e6c31674d5f5505910 |
关闭
pytest_crayons-0.0.7-py3-none-any.whl 的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | f33b6ce9e45a7c41dd54790b8161448df2a51b24090a66fd83e147e8496b95da |
|
MD5 | 2ec7a59d1be5b3977d78c532eb0f614a |
|
BLAKE2b-256 | 2f747d5544154d496b506384abc8dd7fbae9de528b92b05ee9819515769390b9 |