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.
The list of modules described in this chapter is:
typingâ Support for type hints- Specification for the Python Type System
- Type aliases
- NewType
- Annotating callable objects
- Generics
- Annotating tuples
- The type of class objects
- Annotating generators and coroutines
- User-defined generic types
- The
Anytype - Nominal vs structural subtyping
- Module contents
- Deprecation Timeline of Major Features
pydocâ Documentation generator and online help system- Python Development Mode
doctestâ Test interactive Python examplesunittestâ Unit testing frameworkunittest.mockâ mock object libraryunittest.mockâ getting started- Using Mock
- Mock Patching Methods
- Mock for Method Calls on an Object
- 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
- Using side_effect to return per file content
- 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
- Using Mock
testâ Regression tests package for Pythontest.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