[英]Python tox and py.test: how to run just a single test rather than the whole test suite
[英]Idea run/debug py.test single test not the whole suite
我正在创建一个 python 测试套件(使用 py.test)。 我正在 Idea 中编写测试代码,但我不知道如何调试单个测试。
这是我对调试器的设置。 它运行整个测试套件。 因此,我必须运行所有测试,然后才能进行我要调试的测试。
在您的配置中,设置:
testsuite/psa/test_psa_integration.py
TestPsaIntegration and test_psa_integration_example
我不使用 IntelliJ,但在 PyCharm 中,您可以轻松调试测试,而无需每次都经历添加运行/调试配置的繁琐过程。
要使用 PyCharm 执行此操作,请转到: Preferences (or Settings) > Tools > Python Integrated Tools
并将Default test runner
设置为py.test
。
然后,回到你的文件(即test_psa_integration.py
),你可以随便找个地方测试的代码中单击鼠标右键,并选择Run 'py.test in ...'
或Debug 'py.test in...'
这将自动创建一个新的运行/调试配置,如前所述。
另一种方法是将--no-cov --capture=no
到Additional Arguments 中。 要使其他测试文件自动执行此操作,请将它们添加到模板部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.