development.md
1> **Источник:** https://python-all.ru/3.7/library/development.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Инструменты разработки89Модули, описанные в этой главе, помогают писать программное обеспечение. Например, модуль [`pydoc`](https://python-all.ru/3.7/library/pydoc.html#module-pydoc) принимает модуль и генерирует документацию на основе его содержимого. Модули [`doctest`](https://python-all.ru/3.7/library/doctest.html#module-doctest) и [`unittest`](https://python-all.ru/3.7/library/unittest.html#module-unittest) содержат фреймворки для написания модульных тестов, которые автоматически выполняют код и проверяют, что вывод соответствует ожидаемому. **2to3** может переводить исходный код Python 2.x в корректный код Python 3.x.1011Список модулей, описанных в этой главе:1213- [`typing` – Поддержка аннотаций типов](https://python-all.ru/3.7/library/typing.html)1415 - [Псевдонимы типов](https://python-all.ru/3.7/library/typing.html#type-aliases)16 - [NewType](https://python-all.ru/3.7/library/typing.html#newtype)17 - [Callable](https://python-all.ru/3.7/library/typing.html#callable)18 - [Обобщённые типы](https://python-all.ru/3.7/library/typing.html#generics)19 - [Пользовательские обобщённые типы](https://python-all.ru/3.7/library/typing.html#user-defined-generic-types)20 - [Тип `Any`](https://python-all.ru/3.7/library/typing.html#the-any-type)21 - [Классы, функции и декораторы](https://python-all.ru/3.7/library/typing.html#classes-functions-and-decorators)22- [`pydoc` – генератор документации и система интерактивной справки](https://python-all.ru/3.7/library/pydoc.html)23- [`doctest` – тестирование интерактивных примеров Python](https://python-all.ru/3.7/library/doctest.html)2425 - [Простое использование: проверка примеров в строках документации](https://python-all.ru/3.7/library/doctest.html#simple-usage-checking-examples-in-docstrings)26 - [Простое использование: проверка примеров в текстовом файле](https://python-all.ru/3.7/library/doctest.html#simple-usage-checking-examples-in-a-text-file)27 - [Как это работает](https://python-all.ru/3.7/library/doctest.html#how-it-works)2829 - [Какие строки документации проверяются?](https://python-all.ru/3.7/library/doctest.html#which-docstrings-are-examined)30 - [Как распознаются примеры в строках документации?](https://python-all.ru/3.7/library/doctest.html#how-are-docstring-examples-recognized)31 - [Каков контекст выполнения?](https://python-all.ru/3.7/library/doctest.html#what-s-the-execution-context)32 - [А как насчёт исключений?](https://python-all.ru/3.7/library/doctest.html#what-about-exceptions)33 - [Флаги опций](https://python-all.ru/3.7/library/doctest.html#option-flags)34 - [Директивы](https://python-all.ru/3.7/library/doctest.html#directives)35 - [Предупреждения](https://python-all.ru/3.7/library/doctest.html#warnings)36 - [Базовый API](https://python-all.ru/3.7/library/doctest.html#basic-api)37 - [API unittest](https://python-all.ru/3.7/library/doctest.html#unittest-api)38 - [Расширенный API](https://python-all.ru/3.7/library/doctest.html#advanced-api)3940 - [Объекты DocTest](https://python-all.ru/3.7/library/doctest.html#doctest-objects)41 - [Объекты Example](https://python-all.ru/3.7/library/doctest.html#example-objects)42 - [Объекты DocTestFinder](https://python-all.ru/3.7/library/doctest.html#doctestfinder-objects)43 - [Объекты DocTestParser](https://python-all.ru/3.7/library/doctest.html#doctestparser-objects)44 - [Объекты DocTestRunner](https://python-all.ru/3.7/library/doctest.html#doctestrunner-objects)45 - [Объекты OutputChecker](https://python-all.ru/3.7/library/doctest.html#outputchecker-objects)46 - [Отладка](https://python-all.ru/3.7/library/doctest.html#debugging)47 - [Трибуна](https://python-all.ru/3.7/library/doctest.html#soapbox)48- [`unittest` – фреймворк для модульного тестирования](https://python-all.ru/3.7/library/unittest.html)4950 - [Простой пример](https://python-all.ru/3.7/library/unittest.html#basic-example)51 - [Интерфейс командной строки](https://python-all.ru/3.7/library/unittest.html#command-line-interface)5253 - [Параметры командной строки](https://python-all.ru/3.7/library/unittest.html#command-line-options)54 - [Обнаружение тестов](https://python-all.ru/3.7/library/unittest.html#test-discovery)55 - [Организация тестового кода](https://python-all.ru/3.7/library/unittest.html#organizing-test-code)56 - [Повторное использование старого тестового кода](https://python-all.ru/3.7/library/unittest.html#re-using-old-test-code)57 - [Пропуск тестов и ожидаемые сбои](https://python-all.ru/3.7/library/unittest.html#skipping-tests-and-expected-failures)58 - [Различение итераций теста с помощью подтестов](https://python-all.ru/3.7/library/unittest.html#distinguishing-test-iterations-using-subtests)59 - [Классы и функции](https://python-all.ru/3.7/library/unittest.html#classes-and-functions)6061 - [Тестовые случаи](https://python-all.ru/3.7/library/unittest.html#test-cases)6263 - [Устаревшие псевдонимы](https://python-all.ru/3.7/library/unittest.html#deprecated-aliases)64 - [Группировка тестов](https://python-all.ru/3.7/library/unittest.html#grouping-tests)65 - [Загрузка и запуск тестов](https://python-all.ru/3.7/library/unittest.html#loading-and-running-tests)6667 - [Протокол load\_tests](https://python-all.ru/3.7/library/unittest.html#load-tests-protocol)68 - [Фикстуры классов и модулей](https://python-all.ru/3.7/library/unittest.html#class-and-module-fixtures)6970 - [setUpClass и tearDownClass](https://python-all.ru/3.7/library/unittest.html#setupclass-and-teardownclass)71 - [setUpModule и tearDownModule](https://python-all.ru/3.7/library/unittest.html#setupmodule-and-teardownmodule)72 - [Обработка сигналов](https://python-all.ru/3.7/library/unittest.html#signal-handling)73- [`unittest.mock` – библиотека mock-объектов](https://python-all.ru/3.7/library/unittest.mock.html)7475 - [Краткое руководство](https://python-all.ru/3.7/library/unittest.mock.html#quick-guide)76 - [Класс Mock](https://python-all.ru/3.7/library/unittest.mock.html#the-mock-class)7778 - [Вызов](https://python-all.ru/3.7/library/unittest.mock.html#calling)79 - [Удаление атрибутов](https://python-all.ru/3.7/library/unittest.mock.html#deleting-attributes)80 - [Имена Mock и атрибут name](https://python-all.ru/3.7/library/unittest.mock.html#mock-names-and-the-name-attribute)81 - [Прикрепление моков в качестве атрибутов](https://python-all.ru/3.7/library/unittest.mock.html#attaching-mocks-as-attributes)82 - [Патчеры](https://python-all.ru/3.7/library/unittest.mock.html#the-patchers)8384 - [patch](https://python-all.ru/3.7/library/unittest.mock.html#patch)85 - [patch.object](https://python-all.ru/3.7/library/unittest.mock.html#patch-object)86 - [patch.dict](https://python-all.ru/3.7/library/unittest.mock.html#patch-dict)87 - [patch.multiple](https://python-all.ru/3.7/library/unittest.mock.html#patch-multiple)88 - [Методы patch: start и stop](https://python-all.ru/3.7/library/unittest.mock.html#patch-methods-start-and-stop)89 - [patch встроенных объектов](https://python-all.ru/3.7/library/unittest.mock.html#patch-builtins)90 - [TEST\_PREFIX](https://python-all.ru/3.7/library/unittest.mock.html#test-prefix)91 - [Вложение декораторов patch](https://python-all.ru/3.7/library/unittest.mock.html#nesting-patch-decorators)92 - [Где применять patch](https://python-all.ru/3.7/library/unittest.mock.html#where-to-patch)93 - [Подмена дескрипторов и прокси-объектов](https://python-all.ru/3.7/library/unittest.mock.html#patching-descriptors-and-proxy-objects)94 - [MagicMock и поддержка магических методов](https://python-all.ru/3.7/library/unittest.mock.html#magicmock-and-magic-method-support)9596 - [Мокирование магических методов](https://python-all.ru/3.7/library/unittest.mock.html#mocking-magic-methods)97 - [Магический макет](https://python-all.ru/3.7/library/unittest.mock.html#magic-mock)98 - [Вспомогательные средства](https://python-all.ru/3.7/library/unittest.mock.html#helpers)99100 - [sentinel](https://python-all.ru/3.7/library/unittest.mock.html#sentinel)101 - [DEFAULT](https://python-all.ru/3.7/library/unittest.mock.html#default)102 - [вызов](https://python-all.ru/3.7/library/unittest.mock.html#call)103 - [create\_autospec](https://python-all.ru/3.7/library/unittest.mock.html#create-autospec)104 - [ANY](https://python-all.ru/3.7/library/unittest.mock.html#any)105 - [FILTER\_DIR](https://python-all.ru/3.7/library/unittest.mock.html#filter-dir)106 - [mock\_open](https://python-all.ru/3.7/library/unittest.mock.html#mock-open)107 - [Автоспецификация](https://python-all.ru/3.7/library/unittest.mock.html#autospeccing)108 - [Запечатывание моков](https://python-all.ru/3.7/library/unittest.mock.html#sealing-mocks)109- [`unittest.mock` – начало работы](https://python-all.ru/3.7/library/unittest.mock-examples.html)110111 - [Использование Mock](https://python-all.ru/3.7/library/unittest.mock-examples.html#using-mock)112113 - [Методы подмены моков](https://python-all.ru/3.7/library/unittest.mock-examples.html#mock-patching-methods)114 - [Mock для вызовов методов объекта](https://python-all.ru/3.7/library/unittest.mock-examples.html#mock-for-method-calls-on-an-object)115 - [Создание моков для классов](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-classes)116 - [Именование моков](https://python-all.ru/3.7/library/unittest.mock-examples.html#naming-your-mocks)117 - [Отслеживание всех вызовов](https://python-all.ru/3.7/library/unittest.mock-examples.html#tracking-all-calls)118 - [Установка возвращаемых значений и атрибутов](https://python-all.ru/3.7/library/unittest.mock-examples.html#setting-return-values-and-attributes)119 - [Возбуждение исключений с помощью моков](https://python-all.ru/3.7/library/unittest.mock-examples.html#raising-exceptions-with-mocks)120 - [Функции побочного эффекта и итерируемые объекты](https://python-all.ru/3.7/library/unittest.mock-examples.html#side-effect-functions-and-iterables)121 - [Создание мока на основе существующего объекта](https://python-all.ru/3.7/library/unittest.mock-examples.html#creating-a-mock-from-an-existing-object)122 - [Декораторы patch](https://python-all.ru/3.7/library/unittest.mock-examples.html#patch-decorators)123 - [Дополнительные примеры](https://python-all.ru/3.7/library/unittest.mock-examples.html#further-examples)124125 - [Мокирование цепочек вызовов](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-chained-calls)126 - [Частичное мокирование](https://python-all.ru/3.7/library/unittest.mock-examples.html#partial-mocking)127 - [Создание мока для метода-генератора](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-a-generator-method)128 - [Применение одного и того же patch к каждому тестовому методу](https://python-all.ru/3.7/library/unittest.mock-examples.html#applying-the-same-patch-to-every-test-method)129 - [Создание моков для несвязанных методов](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-unbound-methods)130 - [Проверка множественных вызовов с помощью mock](https://python-all.ru/3.7/library/unittest.mock-examples.html#checking-multiple-calls-with-mock)131 - [Работа с изменяемыми аргументами](https://python-all.ru/3.7/library/unittest.mock-examples.html#coping-with-mutable-arguments)132 - [Вложенные подмены](https://python-all.ru/3.7/library/unittest.mock-examples.html#nesting-patches)133 - [Мокирование словаря с помощью MagicMock](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-a-dictionary-with-magicmock)134 - [Подклассы Mock и их атрибуты](https://python-all.ru/3.7/library/unittest.mock-examples.html#mock-subclasses-and-their-attributes)135 - [Мокирование импортов с помощью patch.dict](https://python-all.ru/3.7/library/unittest.mock-examples.html#mocking-imports-with-patch-dict)136 - [Отслеживание порядка вызовов и менее многословные утверждения о вызовах](https://python-all.ru/3.7/library/unittest.mock-examples.html#tracking-order-of-calls-and-less-verbose-call-assertions)137 - [Более сложное сопоставление аргументов](https://python-all.ru/3.7/library/unittest.mock-examples.html#more-complex-argument-matching)138- [2to3 – автоматический перенос кода с Python 2 на Python 3](https://python-all.ru/3.7/library/2to3.html)139140 - [Использование 2to3](https://python-all.ru/3.7/library/2to3.html#using-2to3)141 - [Фиксы](https://python-all.ru/3.7/library/2to3.html#fixers)142 - [`lib2to3` – библиотека 2to3](https://python-all.ru/3.7/library/2to3.html#module-lib2to3)143- [`test` – Пакет регрессионных тестов для Python](https://python-all.ru/3.7/library/test.html)144145 - [Написание модульных тестов для пакета `test`](https://python-all.ru/3.7/library/test.html#writing-unit-tests-for-the-test-package)146 - [Запуск тестов с помощью интерфейса командной строки](https://python-all.ru/3.7/library/test.html#running-tests-using-the-command-line-interface)147- [`test.support` – Утилиты для набора тестов Python](https://python-all.ru/3.7/library/test.html#module-test.support)148- [`test.support.script_helper` – Утилиты для тестов выполнения Python](https://python-all.ru/3.7/library/test.html#module-test.support.script_helper)149150См. также режим разработки Python: параметр [`-X`](https://python-all.ru/3.7/using/cmdline.html#id5) `dev` и переменная окружения [`PYTHONDEVMODE`](https://python-all.ru/3.7/using/cmdline.html#envvar-PYTHONDEVMODE).151