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— Dokumentationserzeuger und Online-Hilfesystem- 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— Paket mit den Regressionstests für Pythontest.support— Werkzeuge für die Python-Testsuitetest.support.socket_helper— Werkzeuge für Socket-Teststest.support.script_helper— Werkzeuge für die Tests der Python-Ausführungtest.support.bytecode_helper— Hilfswerkzeuge, um die korrekte Bytecode-Erzeugung zu prüfentest.support.threading_helper— Werkzeuge für Threading-Teststest.support.os_helper— Werkzeuge für os-Teststest.support.import_helper— Werkzeuge für Import-Teststest.support.warnings_helper— Werkzeuge für Warnungs-Tests