![](/img/trans.png)
[英]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.