一个pytest插件,用于限制输出仅限于您需要查看的内容。
项目描述
一个pytest插件,将pytest的输出限制为仅显示您需要查看的内容。
我对pytest的最大个人抱怨之一是它的控制台输出非常、非常啰嗦。它会告诉您它正在开始。它会告诉您它正在工作。它会告诉您它已完成。如果测试失败,它不仅会告诉您哪个测试失败,还会在您的控制台上倾倒一页又一页的代码。
而且它还以辉煌的技术色彩完成这一切。希望您有完美的色觉,并且您的控制台颜色选择具有对比度兼容性。
是的:pytest有很多很多命令行选项。其中一些行为可以通过功能标志进行配置或关闭。但有些人(可能至少是pytest核心团队)喜欢pytest的输出格式。所以,如果你是团队中唯一一个不喜欢pytest输出格式的人,你不能将“更好”的选项提交到默认配置中 - 你每次运行测试套件时都必须手动指定选项。
幸运的是,pytest还有一个插件系统,我们可以通过它来解决这个问题。
pytest-tldr是一个插件,它提供最小化输出,以单色显示,同时仍然给出测试套件进度的指示。
安装
您可以通过从PyPI使用pip安装“pytest-tldr”
$ pip install pytest-tldr
然后您可以像平常一样运行您的测试套件
$ pytest tests EF..s..........ux ====================================================================== ERROR: tests/test_things.py::TestTests::test_error ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rkm/projects/sample/tests/test_things.py", line 182, in test_error raise Exception("this is really bad") Exception: this is really bad ====================================================================== FAIL: tests/test_things.py::TestTests::test_failed ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rkm/projects/sample/tests/test_things.py", line 179, in test_failed self.fail('failed!') File "/Users/rkm/.pyenv/versions/3.6.2/lib/python3.6/unittest/case.py", line 670, in fail raise self.failureException(msg) AssertionError: failed! ====================================================================== UNEXPECTED SUCCESS: tests/test_things.py::TestTests::test_upassed ---------------------------------------------------------------------- Ran 17 tests in 2.11s FAILED (errors=1, failures=1, skipped=1, expected failures=1, unexpected successes=1)
或者,如果您需要更多细节,可以使用详细度选项
$ pytest tests -v platform darwin -- Python 3.6.2 pytest==3.6.1 py==1.5.2 pluggy==0.6.0 rootdir: /Users/rkm/projects/sample plugins: xdist-1.22.0, forked-0.2, tldr-0.1.0 cachedir: .pytest_cache ---------------------------------------------------------------------- tests/test_things.py::TestTests::test_error ... ERROR tests/test_things.py::TestTests::test_failed ... FAIL tests/test_things.py::TestTests::test_output ... ok tests/test_things.py::TestTests::test_passed ... ok tests/test_things.py::TestTests::test_skipped ... Skipped: tra-la-la tests/test_things.py::TestTests::test_thing_0 ... ok tests/test_things.py::TestTests::test_thing_1 ... ok tests/test_things.py::TestTests::test_thing_2 ... ok tests/test_things.py::TestTests::test_thing_3 ... ok tests/test_things.py::TestTests::test_thing_4 ... ok tests/test_things.py::TestTests::test_thing_5 ... ok tests/test_things.py::TestTests::test_thing_6 ... ok tests/test_things.py::TestTests::test_thing_7 ... ok tests/test_things.py::TestTests::test_thing_8 ... ok tests/test_things.py::TestTests::test_thing_9 ... ok tests/test_things.py::TestTests::test_upassed ... unexpected success tests/test_things.py::TestTests::test_xfailed ... expected failure ====================================================================== ERROR: tests/test_things.py::TestTests::test_error ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rkm/projects/sample/tests/test_things.py", line 182, in test_error raise Exception("this is really bad") Exception: this is really bad ====================================================================== FAIL: tests/test_things.py::TestTests::test_failed ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rkm/projects/sample/tests/test_things.py", line 179, in test_failed self.fail('failed!') File "/Users/rkm/.pyenv/versions/3.6.2/lib/python3.6/unittest/case.py", line 670, in fail raise self.failureException(msg) AssertionError: failed! ====================================================================== UNEXPECTED SUCCESS: tests/test_things.py::TestTests::test_upassed ---------------------------------------------------------------------- Ran 17 tests in 2.07s FAILED (errors=1, failures=1, skipped=1, expected failures=1, unexpected successes=1)
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。
源分布
pytest-tldr-0.2.5.tar.gz (11.1 kB 查看散列)
构建分布
pytest_tldr-0.2.5-py3-none-any.whl (7.5 kB 查看散列)
关闭
pytest-tldr-0.2.5.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 43f43fe758569df620c433a79d3cbee698e77268efebbc6e22ce1e66095a0881 |
|
MD5 | 9b0c9ef22a75470112a0379585b9ce4d |
|
BLAKE2b-256 | f59ab611bda531adec3000023bcf7af19e8be75574585642a9c62fa317591120 |
关闭
pytest_tldr-0.2.5-py3-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | abc51c90d31e1a188ebf1800a73a65be73df9d94b01c4c4a494097282a120bf9 |
|
MD5 | 236fa33af2feaa316c5862cb9bb6b32a |
|
BLAKE2b-256 | c0ede22642e43139ffc541db5d1fb06e0d220ccac1bb7381559b020801c80cf0 |