Outils de développement¶
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.
La liste des modules documentés dans ce chapitre est :
typing
— Prise en charge des annotations de type- Specification for the Python Type System
- Alias de type
- NewType
- Annotating callable objects
- Génériques
- Annotating tuples
- The type of class objects
- Annotating generators and coroutines
- Types génériques définis par l'utilisateur
- Le type
Any
- Sous-typage nominal et sous-typage structurel
- Module contents
- Étapes d'Obsolescence des Fonctionnalités Majeures
pydoc
--- Documentation generator and online help system- Python Development Mode
doctest
--- Test interactive Python examplesunittest
--- Unit testing framework- Exemple basique
- Interface en ligne de commande
- Découverte des tests
- Organiser le code de test
- Réutilisation d'ancien code de test
- Ignorer des tests et des erreurs prévisibles
- Distinguer les itérations de test à l'aide de sous-tests
- Classes et fonctions
- Classes et modules d'aménagements des tests
- Traitement des signaux
unittest.mock
--- mock object libraryunittest.mock
--- getting started- Utilisation de Mock ou l'art de singer
- Simulation des méthodes
- S'assurer de la bonne utilisation d'un objet
- Simulation des 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
- Utilisation de Mock ou l'art de singer
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