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