開發(fā)工具?
本章中描述的各模塊可幫你編寫 Python 程序。例如,pydoc
模塊接受一個(gè)模塊并根據(jù)該模塊的內(nèi)容來(lái)生成文檔。doctest
和 unittest
這兩個(gè)模塊包含了用于編寫單元測(cè)試的框架,并可用于自動(dòng)測(cè)試所編寫的代碼,驗(yàn)證預(yù)期的輸出是否產(chǎn)生。2to3 程序能夠?qū)?Python 2.x 源代碼翻譯成有效的 Python 3.x 源代碼。
本章中描述的模塊列表是:
typing
--- 類型提示支持pydoc
--- 文檔生成器和在線幫助系統(tǒng)- Python 開發(fā)模式
- Python 開發(fā)模式的效果
- ResourceWarning 示例
- 文件描述符錯(cuò)誤示例
doctest
--- 測(cè)試交互性的Python示例unittest
--- 單元測(cè)試框架unittest.mock
--- 模擬對(duì)象庫(kù)unittest.mock
上手指南- 使用 mock
- 模擬方法調(diào)用
- 對(duì)象上的方法調(diào)用的 mock
- Mocking Classes
- Naming your mocks
- Tracking all Calls
- Setting Return Values and Attributes
- Raising exceptions with mocks
- Side effect functions and iterables
- Mocking asynchronous iterators
- Mocking asynchronous context manager
- Creating a Mock from an Existing Object
- 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
- 使用 mock
- 2to3 - 自動(dòng)將 Python 2 代碼轉(zhuǎn)為 Python 3 代碼
test
--- Python回歸測(cè)試包test.support
--- Utilities for the Python test suitetest.support.socket_helper
--- Utilities for socket teststest.support.script_helper
--- Utilities for the Python execution teststest.support.bytecode_helper
--- Support tools for testing correct bytecode generationtest.support.threading_helper
--- Utilities for threading teststest.support.os_helper
--- Utilities for os teststest.support.import_helper
--- Utilities for import teststest.support.warnings_helper
--- Utilities for warnings tests