development.md
1> **Источник:** https://python-all.ru/3.9/library/development.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Инструменты разработки89Модули, описанные в этой главе, помогают писать программное обеспечение. Например, модуль [`pydoc`](https://python-all.ru/3.9/library/pydoc.html#module-pydoc) принимает модуль и генерирует документацию на основе его содержимого. Модули [`doctest`](https://python-all.ru/3.9/library/doctest.html#module-doctest) и [`unittest`](https://python-all.ru/3.9/library/unittest.html#module-unittest) содержат фреймворки для написания модульных тестов, которые автоматически выполняют код и проверяют, что вывод соответствует ожидаемому. **2to3** может переводить исходный код Python 2.x в корректный код Python 3.x.1011Список модулей, описанных в этой главе:1213- [`typing` – Поддержка аннотаций типов](https://python-all.ru/3.9/library/typing.html)1415 - [Соответствующие PEPs](https://python-all.ru/3.9/library/typing.html#relevant-peps)16 - [Псевдонимы типов](https://python-all.ru/3.9/library/typing.html#type-aliases)17 - [NewType](https://python-all.ru/3.9/library/typing.html#newtype)18 - [Callable](https://python-all.ru/3.9/library/typing.html#callable)19 - [Обобщённые типы](https://python-all.ru/3.9/library/typing.html#generics)20 - [Пользовательские обобщённые типы](https://python-all.ru/3.9/library/typing.html#user-defined-generic-types)21 - [Тип `Any`](https://python-all.ru/3.9/library/typing.html#the-any-type)22 - [Номинальное и структурное подтипирование](https://python-all.ru/3.9/library/typing.html#nominal-vs-structural-subtyping)23 - [Содержание модуля](https://python-all.ru/3.9/library/typing.html#module-contents)2425 - [Специальные примитивы типизации](https://python-all.ru/3.9/library/typing.html#special-typing-primitives)2627 - [Специальные типы](https://python-all.ru/3.9/library/typing.html#special-types)28 - [Специальные формы](https://python-all.ru/3.9/library/typing.html#special-forms)29 - [Построение обобщённых типов](https://python-all.ru/3.9/library/typing.html#building-generic-types)30 - [Другие специальные директивы](https://python-all.ru/3.9/library/typing.html#other-special-directives)31 - [Конкретные обобщённые коллекции](https://python-all.ru/3.9/library/typing.html#generic-concrete-collections)3233 - [Соответствующие встроенным типам](https://python-all.ru/3.9/library/typing.html#corresponding-to-built-in-types)34 - [Соответствующие типам из `collections`](https://python-all.ru/3.9/library/typing.html#corresponding-to-types-in-collections)35 - [Другие конкретные типы](https://python-all.ru/3.9/library/typing.html#other-concrete-types)36 - [Абстрактные базовые классы](https://python-all.ru/3.9/library/typing.html#abstract-base-classes)3738 - [Соответствующие коллекциям из `collections.abc`](https://python-all.ru/3.9/library/typing.html#corresponding-to-collections-in-collections-abc)39 - [Соответствующие другим типам из `collections.abc`](https://python-all.ru/3.9/library/typing.html#corresponding-to-other-types-in-collections-abc)40 - [Асинхронное программирование](https://python-all.ru/3.9/library/typing.html#asynchronous-programming)41 - [Типы менеджеров контекста](https://python-all.ru/3.9/library/typing.html#context-manager-types)42 - [Протоколы](https://python-all.ru/3.9/library/typing.html#protocols)43 - [Функции и декораторы](https://python-all.ru/3.9/library/typing.html#functions-and-decorators)44 - [Вспомогательные функции интроспекции](https://python-all.ru/3.9/library/typing.html#introspection-helpers)45 - [Константа](https://python-all.ru/3.9/library/typing.html#constant)46- [`pydoc` – генератор документации и система интерактивной справки](https://python-all.ru/3.9/library/pydoc.html)47- [Режим разработки Python](https://python-all.ru/3.9/library/devmode.html)48- [Эффекты режима разработки Python](https://python-all.ru/3.9/library/devmode.html#effects-of-the-python-development-mode)49- [Пример ResourceWarning](https://python-all.ru/3.9/library/devmode.html#resourcewarning-example)50- [Пример ошибки с некорректным файловым дескриптором](https://python-all.ru/3.9/library/devmode.html#bad-file-descriptor-error-example)51- [`doctest` – тестирование интерактивных примеров Python](https://python-all.ru/3.9/library/doctest.html)5253 - [Простое использование: проверка примеров в строках документации](https://python-all.ru/3.9/library/doctest.html#simple-usage-checking-examples-in-docstrings)54 - [Простое использование: проверка примеров в текстовом файле](https://python-all.ru/3.9/library/doctest.html#simple-usage-checking-examples-in-a-text-file)55 - [Как это работает](https://python-all.ru/3.9/library/doctest.html#how-it-works)5657 - [Какие строки документации проверяются?](https://python-all.ru/3.9/library/doctest.html#which-docstrings-are-examined)58 - [Как распознаются примеры в строках документации?](https://python-all.ru/3.9/library/doctest.html#how-are-docstring-examples-recognized)59 - [Каков контекст выполнения?](https://python-all.ru/3.9/library/doctest.html#what-s-the-execution-context)60 - [А как насчёт исключений?](https://python-all.ru/3.9/library/doctest.html#what-about-exceptions)61 - [Флаги опций](https://python-all.ru/3.9/library/doctest.html#option-flags)62 - [Директивы](https://python-all.ru/3.9/library/doctest.html#directives)63 - [Предупреждения](https://python-all.ru/3.9/library/doctest.html#warnings)64 - [Базовый API](https://python-all.ru/3.9/library/doctest.html#basic-api)65 - [API unittest](https://python-all.ru/3.9/library/doctest.html#unittest-api)66 - [Расширенный API](https://python-all.ru/3.9/library/doctest.html#advanced-api)6768 - [Объекты DocTest](https://python-all.ru/3.9/library/doctest.html#doctest-objects)69 - [Объекты Example](https://python-all.ru/3.9/library/doctest.html#example-objects)70 - [Объекты DocTestFinder](https://python-all.ru/3.9/library/doctest.html#doctestfinder-objects)71 - [Объекты DocTestParser](https://python-all.ru/3.9/library/doctest.html#doctestparser-objects)72 - [Объекты DocTestRunner](https://python-all.ru/3.9/library/doctest.html#doctestrunner-objects)73 - [Объекты OutputChecker](https://python-all.ru/3.9/library/doctest.html#outputchecker-objects)74 - [Отладка](https://python-all.ru/3.9/library/doctest.html#debugging)75 - [Трибуна](https://python-all.ru/3.9/library/doctest.html#soapbox)76- [`unittest` – фреймворк для модульного тестирования](https://python-all.ru/3.9/library/unittest.html)7778 - [Простой пример](https://python-all.ru/3.9/library/unittest.html#basic-example)79 - [Интерфейс командной строки](https://python-all.ru/3.9/library/unittest.html#command-line-interface)8081 - [Параметры командной строки](https://python-all.ru/3.9/library/unittest.html#command-line-options)82 - [Обнаружение тестов](https://python-all.ru/3.9/library/unittest.html#test-discovery)83 - [Организация тестового кода](https://python-all.ru/3.9/library/unittest.html#organizing-test-code)84 - [Повторное использование старого тестового кода](https://python-all.ru/3.9/library/unittest.html#re-using-old-test-code)85 - [Пропуск тестов и ожидаемые сбои](https://python-all.ru/3.9/library/unittest.html#skipping-tests-and-expected-failures)86 - [Различение итераций теста с помощью подтестов](https://python-all.ru/3.9/library/unittest.html#distinguishing-test-iterations-using-subtests)87 - [Классы и функции](https://python-all.ru/3.9/library/unittest.html#classes-and-functions)8889 - [Тестовые случаи](https://python-all.ru/3.9/library/unittest.html#test-cases)9091 - [Устаревшие псевдонимы](https://python-all.ru/3.9/library/unittest.html#deprecated-aliases)92 - [Группировка тестов](https://python-all.ru/3.9/library/unittest.html#grouping-tests)93 - [Загрузка и запуск тестов](https://python-all.ru/3.9/library/unittest.html#loading-and-running-tests)9495 - [Протокол load\_tests](https://python-all.ru/3.9/library/unittest.html#load-tests-protocol)96 - [Фикстуры классов и модулей](https://python-all.ru/3.9/library/unittest.html#class-and-module-fixtures)9798 - [setUpClass и tearDownClass](https://python-all.ru/3.9/library/unittest.html#setupclass-and-teardownclass)99 - [setUpModule и tearDownModule](https://python-all.ru/3.9/library/unittest.html#setupmodule-and-teardownmodule)100 - [Обработка сигналов](https://python-all.ru/3.9/library/unittest.html#signal-handling)101- [`unittest.mock` – библиотека mock-объектов](https://python-all.ru/3.9/library/unittest.mock.html)102103 - [Краткое руководство](https://python-all.ru/3.9/library/unittest.mock.html#quick-guide)104 - [Класс Mock](https://python-all.ru/3.9/library/unittest.mock.html#the-mock-class)105106 - [Вызов](https://python-all.ru/3.9/library/unittest.mock.html#calling)107 - [Удаление атрибутов](https://python-all.ru/3.9/library/unittest.mock.html#deleting-attributes)108 - [Имена Mock и атрибут name](https://python-all.ru/3.9/library/unittest.mock.html#mock-names-and-the-name-attribute)109 - [Прикрепление моков в качестве атрибутов](https://python-all.ru/3.9/library/unittest.mock.html#attaching-mocks-as-attributes)110 - [Патчеры](https://python-all.ru/3.9/library/unittest.mock.html#the-patchers)111112 - [patch](https://python-all.ru/3.9/library/unittest.mock.html#patch)113 - [patch.object](https://python-all.ru/3.9/library/unittest.mock.html#patch-object)114 - [patch.dict](https://python-all.ru/3.9/library/unittest.mock.html#patch-dict)115 - [patch.multiple](https://python-all.ru/3.9/library/unittest.mock.html#patch-multiple)116 - [Методы patch: start и stop](https://python-all.ru/3.9/library/unittest.mock.html#patch-methods-start-and-stop)117 - [patch встроенных объектов](https://python-all.ru/3.9/library/unittest.mock.html#patch-builtins)118 - [TEST\_PREFIX](https://python-all.ru/3.9/library/unittest.mock.html#test-prefix)119 - [Вложение декораторов patch](https://python-all.ru/3.9/library/unittest.mock.html#nesting-patch-decorators)120 - [Где применять patch](https://python-all.ru/3.9/library/unittest.mock.html#where-to-patch)121 - [Подмена дескрипторов и прокси-объектов](https://python-all.ru/3.9/library/unittest.mock.html#patching-descriptors-and-proxy-objects)122 - [MagicMock и поддержка магических методов](https://python-all.ru/3.9/library/unittest.mock.html#magicmock-and-magic-method-support)123124 - [Мокирование магических методов](https://python-all.ru/3.9/library/unittest.mock.html#mocking-magic-methods)125 - [Магический макет](https://python-all.ru/3.9/library/unittest.mock.html#magic-mock)126 - [Вспомогательные средства](https://python-all.ru/3.9/library/unittest.mock.html#helpers)127128 - [sentinel](https://python-all.ru/3.9/library/unittest.mock.html#sentinel)129 - [DEFAULT](https://python-all.ru/3.9/library/unittest.mock.html#default)130 - [вызов](https://python-all.ru/3.9/library/unittest.mock.html#call)131 - [create\_autospec](https://python-all.ru/3.9/library/unittest.mock.html#create-autospec)132 - [ANY](https://python-all.ru/3.9/library/unittest.mock.html#any)133 - [FILTER\_DIR](https://python-all.ru/3.9/library/unittest.mock.html#filter-dir)134 - [mock\_open](https://python-all.ru/3.9/library/unittest.mock.html#mock-open)135 - [Автоспецификация](https://python-all.ru/3.9/library/unittest.mock.html#autospeccing)136 - [Запечатывание моков](https://python-all.ru/3.9/library/unittest.mock.html#sealing-mocks)137- [`unittest.mock` – начало работы](https://python-all.ru/3.9/library/unittest.mock-examples.html)138139 - [Использование Mock](https://python-all.ru/3.9/library/unittest.mock-examples.html#using-mock)140141 - [Методы подмены моков](https://python-all.ru/3.9/library/unittest.mock-examples.html#mock-patching-methods)142 - [Mock для вызовов методов объекта](https://python-all.ru/3.9/library/unittest.mock-examples.html#mock-for-method-calls-on-an-object)143 - [Создание моков для классов](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-classes)144 - [Именование моков](https://python-all.ru/3.9/library/unittest.mock-examples.html#naming-your-mocks)145 - [Отслеживание всех вызовов](https://python-all.ru/3.9/library/unittest.mock-examples.html#tracking-all-calls)146 - [Установка возвращаемых значений и атрибутов](https://python-all.ru/3.9/library/unittest.mock-examples.html#setting-return-values-and-attributes)147 - [Возбуждение исключений с помощью моков](https://python-all.ru/3.9/library/unittest.mock-examples.html#raising-exceptions-with-mocks)148 - [Функции побочного эффекта и итерируемые объекты](https://python-all.ru/3.9/library/unittest.mock-examples.html#side-effect-functions-and-iterables)149 - [Мокирование асинхронных итераторов](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-asynchronous-iterators)150 - [Мокирование асинхронного контекстного менеджера](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-asynchronous-context-manager)151 - [Создание мока на основе существующего объекта](https://python-all.ru/3.9/library/unittest.mock-examples.html#creating-a-mock-from-an-existing-object)152 - [Декораторы patch](https://python-all.ru/3.9/library/unittest.mock-examples.html#patch-decorators)153 - [Дополнительные примеры](https://python-all.ru/3.9/library/unittest.mock-examples.html#further-examples)154155 - [Мокирование цепочек вызовов](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-chained-calls)156 - [Частичное мокирование](https://python-all.ru/3.9/library/unittest.mock-examples.html#partial-mocking)157 - [Создание мока для метода-генератора](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-a-generator-method)158 - [Применение одного и того же patch к каждому тестовому методу](https://python-all.ru/3.9/library/unittest.mock-examples.html#applying-the-same-patch-to-every-test-method)159 - [Создание моков для несвязанных методов](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-unbound-methods)160 - [Проверка множественных вызовов с помощью mock](https://python-all.ru/3.9/library/unittest.mock-examples.html#checking-multiple-calls-with-mock)161 - [Работа с изменяемыми аргументами](https://python-all.ru/3.9/library/unittest.mock-examples.html#coping-with-mutable-arguments)162 - [Вложенные подмены](https://python-all.ru/3.9/library/unittest.mock-examples.html#nesting-patches)163 - [Мокирование словаря с помощью MagicMock](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-a-dictionary-with-magicmock)164 - [Подклассы Mock и их атрибуты](https://python-all.ru/3.9/library/unittest.mock-examples.html#mock-subclasses-and-their-attributes)165 - [Мокирование импортов с помощью patch.dict](https://python-all.ru/3.9/library/unittest.mock-examples.html#mocking-imports-with-patch-dict)166 - [Отслеживание порядка вызовов и менее многословные утверждения о вызовах](https://python-all.ru/3.9/library/unittest.mock-examples.html#tracking-order-of-calls-and-less-verbose-call-assertions)167 - [Более сложное сопоставление аргументов](https://python-all.ru/3.9/library/unittest.mock-examples.html#more-complex-argument-matching)168- [2to3 – автоматический перенос кода с Python 2 на Python 3](https://python-all.ru/3.9/library/2to3.html)169170 - [Использование 2to3](https://python-all.ru/3.9/library/2to3.html#using-2to3)171 - [Фиксы](https://python-all.ru/3.9/library/2to3.html#fixers)172 - [`lib2to3` – библиотека 2to3](https://python-all.ru/3.9/library/2to3.html#module-lib2to3)173- [`test` – Пакет регрессионных тестов для Python](https://python-all.ru/3.9/library/test.html)174175 - [Написание модульных тестов для пакета `test`](https://python-all.ru/3.9/library/test.html#writing-unit-tests-for-the-test-package)176 - [Запуск тестов с помощью интерфейса командной строки](https://python-all.ru/3.9/library/test.html#running-tests-using-the-command-line-interface)177- [`test.support` – Утилиты для набора тестов Python](https://python-all.ru/3.9/library/test.html#module-test.support)178- [`test.support.socket_helper` – Утилиты для тестирования сокетов](https://python-all.ru/3.9/library/test.html#module-test.support.socket_helper)179- [`test.support.script_helper` – Утилиты для тестов выполнения Python](https://python-all.ru/3.9/library/test.html#module-test.support.script_helper)180- [`test.support.bytecode_helper` – Вспомогательные инструменты для тестирования корректной генерации байт-кода](https://python-all.ru/3.9/library/test.html#module-test.support.bytecode_helper)181