开发工具¶
本章中描述的各模块可帮你编写 Python 程序。例如,pydoc 模块接受一个模块并根据该模块的内容来生成文档。doctest 和 unittest 这两个模块包含了用于编写单元测试的框架,并可用于自动测试所编写的代码,验证预期的输出是否产生。2to3 程序能够将 Python 2.x 源代码翻译成有效的 Python 3.x 源代码。
本章中描述的模块列表是:
typing--- 类型提示支持pydoc--- 文档生成器和在线帮助系统- Python 开发模式
 - Python 开发模式的效果
 - ResourceWarning 示例
 - 文件描述符错误示例
 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.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