[英]How to run a Python unit test with the Atom editor?
我正在嘗試使用Atom編輯器,並想知道如何使用鍵盤快捷鍵運行Python單元測試。
安裝
單元測試示例test.py
編寫單元測試並將其另存為test.py
import unittest class MyTest(unittest.TestCase): def test_pass(self): pass def test_fail(self): call_method_that_does_not_exist() if __name__ == '__main__': unittest.main()
運行單元測試
控制台輸出
因為單元測試test_fail
將失敗,這將是控制台輸出:
E.
======================================================================
ERROR: test_fail (__main__.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Lernkurve/Desktop/PythonDemos/a.py", line 9, in test_fail
call_method_that_does_not_exist()
NameError: global name 'call_method_that_does_not_exist' is not defined
----------------------------------------------------------------------
Ran 2 tests in 0.000s
FAILED (errors=1)
[Finished in 0.047s]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.