開發工具?
本章中描述的各模塊可幫你編寫 Python 程序。例如,pydoc 模塊接受一個模塊并根據該模塊的內容來生成文檔。doctest 和 unittest 這兩個模塊包含了用于編寫單元測試的框架,并可用于自動測試所編寫的代碼,驗證預期的輸出是否產生。2to3 程序能夠將 Python 2.x 源代碼翻譯成有效的 Python 3.x 源代碼。
本章中描述的模塊列表是:
typing--- 類型標注支持pydoc--- 文檔生成器和在線幫助系統doctest--- 測試交互性的Python示例unittest--- 單元測試框架unittest.mock--- 模擬對象庫unittest.mock上手指南- 使用 mock
- Patch Decorators
- Further Examples
- Mocking chained calls
- Partial mocking
- Mocking a Generator Method
- Applying the same patch to every test method
- Mocking Unbound Methods
- Checking multiple calls with mock
- Coping with mutable arguments
- Nesting Patches
- Mocking a dictionary with MagicMock
- Mock subclasses and their attributes
- Mocking imports with patch.dict
- Tracking order of calls and less verbose call assertions
- More complex argument matching
- 2to3 - 自動將 Python 2 代碼轉為 Python 3 代碼
test--- Python回歸測試包test.support--- Utilities for the Python test suitetest.support.script_helper--- Utilities for the Python execution tests
另請參看 Python 開發模式: -X dev 選項以及 PYTHONDEVMODE 環境變量。
