26. Development Tools
The modules described in this chapter help you write software. For example, the pydoc module takes a module and generates documentation based on the module’s contents. The doctest and unittest modules contains frameworks for writing unit tests that automatically exercise code and verify that the expected output is produced. 2to3 can translate Python 2.x source code into valid Python 3.x code.
The list of modules described in this chapter is:
- 26.1. pydoc — Documentation generator and online help system
- 26.2. doctest — Test interactive Python examples
- 26.3. unittest — Unit testing framework
- 26.3.1. Basic example
- 26.3.2. Command-Line Interface
- 26.3.3. Test Discovery
- 26.3.4. Organizing test code
- 26.3.5. Re-using old test code
- 26.3.6. Skipping tests and expected failures
- 26.3.7. Distinguishing test iterations using subtests
- 26.3.8. Classes and functions
- 26.3.9. Class and Module Fixtures
- 26.3.10. Signal Handling
- 26.4. unittest.mock — mock object library
- 26.5. unittest.mock — getting started
- 26.5.1. Using Mock
- 26.5.1.1. Mock Patching Methods
- 26.5.1.2. Mock for Method Calls on an Object
- 26.5.1.3. Mocking Classes
- 26.5.1.4. Naming your mocks
- 26.5.1.5. Tracking all Calls
- 26.5.1.6. Setting Return Values and Attributes
- 26.5.1.7. Raising exceptions with mocks
- 26.5.1.8. Side effect functions and iterables
- 26.5.1.9. Creating a Mock from an Existing Object
- 26.5.2. Patch Decorators
- 26.5.3. Further Examples
- 26.5.3.1. Mocking chained calls
- 26.5.3.2. Partial mocking
- 26.5.3.3. Mocking a Generator Method
- 26.5.3.4. Applying the same patch to every test method
- 26.5.3.5. Mocking Unbound Methods
- 26.5.3.6. Checking multiple calls with mock
- 26.5.3.7. Coping with mutable arguments
- 26.5.3.8. Nesting Patches
- 26.5.3.9. Mocking a dictionary with MagicMock
- 26.5.3.10. Mock subclasses and their attributes
- 26.5.3.11. Mocking imports with patch.dict
- 26.5.3.12. Tracking order of calls and less verbose call assertions
- 26.5.3.13. More complex argument matching
- 26.5.1. Using Mock
- 26.6. 2to3 - Automated Python 2 to 3 code translation
- 26.7. test — Regression tests package for Python
- 26.8. test.support — Utilities for the Python test suite