python unittest套件加載用例時,出現No tests were found,Empty test suite


  • 錯誤信息:

之前運行好好的腳本,突然報No tests were found,Empty test suite,詳情錯誤信息如下所示:

Launching pytest with arguments loanlaterOfflineExtend.py::LoanlaterOfflineExtend::test_ConfirmLoanOffline3 in D:\script\py_jjd\TestCase

============================= test session starts =============================
platform win32 -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: D:\script\py_jjd\TestCase, inifile:

======================== no tests ran in 0.36 seconds =========================
ERROR: not found: D:\script\py_jjd\TestCase\loanlaterOfflineExtend.py::LoanlaterOfflineExtend::test_ConfirmLoanOffline3
(no name 'D:\\script\\py_jjd\\TestCase\\loanlaterOfflineExtend.py::LoanlaterOfflineExtend::test_ConfirmLoanOffline3' in any of [<UnitTestCase 'LoanlaterOfflineExtend'>])

 

 

  • 解決方法:個人習慣,類似場景用例命名規則在后面用數字加以區別例如test_a1、test_a2、test_a3,python之前的版本是支持這樣設計的,但現在認為這樣的為重復用例名

 

 

將用例名從 test_a1、test_a2、test_a3 改test_aA、test_aB、test_aC 如下圖所示就可以過了:

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM