简体   繁体   English

在PyCharm中,如何在运行unittests时向pytest添加自定义参数?

[英]In PyCharm, how do you add a custom parameter to pytest when running unittests?

I'm running a Python unittest in pycharm. 我在pycharm中运行Python单元测试。 This executes the command: 这将执行以下命令:

/<path>/python /<path>/_jb_pytest_runner.py --target my_function_test_base.py::MyFunctionTestBase

Launching pytest with arguments my_function_test_base.py::MyFunctionTestBase in //tests 在// tests中使用参数my_function_test_base.py::MyFunctionTestBase启动pytest

I would like to add a pytest option --tb=1 that I found in this answer: Make Python unittest show AssertionError but no Traceback 我想添加一个在这个答案中找到的pytest选项--tb=1使Python unittest显示AssertionError但没有Traceback

I don't know how to do that under PyCharm. 我不知道在PyCharm下该怎么做。

Answering on behalf of comments, indeed Additional Arguments in the Edit Configurations section does pass arguments through to py.test . 实际上,“ Edit Configurations”部分中的“ Additional Arguments”代表注释进行py.test确实将参数传递给py.test My error was in misusing one of the arguments, obfuscating the fact that Additional Arguments was passing on the arguments as expected. 我的错误在于误用了其中一个参数,从而混淆了“ Additional Arguments正在按预期传递Additional Arguments的事实。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM