> **Источник:** https://python-all.ru/3.15/library/development.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# Инструменты разработки

Модули, описанные в этой главе, помогают писать программное обеспечение. Например, модуль [`pydoc`](https://python-all.ru/3.15/library/pydoc.html#module-pydoc) принимает модуль и генерирует документацию на основе его содержимого. Модули [`doctest`](https://python-all.ru/3.15/library/doctest.html#module-doctest) и [`unittest`](https://python-all.ru/3.15/library/unittest.html#module-unittest) содержат фреймворки для написания модульных тестов, которые автоматически выполняют код и проверяют, что выводится ожидаемый результат.

Список модулей, описанных в этой главе:

- [`typing` – Поддержка аннотаций типов](https://python-all.ru/3.15/library/typing.html)

  - [Спецификация системы типов Python](https://python-all.ru/3.15/library/typing.html#specification-for-the-python-type-system)
  - [Псевдонимы типов](https://python-all.ru/3.15/library/typing.html#type-aliases)
  - [NewType](https://python-all.ru/3.15/library/typing.html#newtype)
  - [Аннотирование вызываемых объектов](https://python-all.ru/3.15/library/typing.html#annotating-callable-objects)
  - [Обобщённые типы](https://python-all.ru/3.15/library/typing.html#generics)
  - [Аннотирование кортежей](https://python-all.ru/3.15/library/typing.html#annotating-tuples)
  - [Тип объектов классов](https://python-all.ru/3.15/library/typing.html#the-type-of-class-objects)
  - [Аннотирование генераторов и корутин](https://python-all.ru/3.15/library/typing.html#annotating-generators-and-coroutines)
  - [Пользовательские обобщённые типы](https://python-all.ru/3.15/library/typing.html#user-defined-generic-types)
  - [Тип `Any`](https://python-all.ru/3.15/library/typing.html#the-any-type)
  - [Номинальное и структурное подтипирование](https://python-all.ru/3.15/library/typing.html#nominal-vs-structural-subtyping)
  - [Содержание модуля](https://python-all.ru/3.15/library/typing.html#module-contents)

    - [Специальные примитивы типизации](https://python-all.ru/3.15/library/typing.html#special-typing-primitives)

      - [Специальные типы](https://python-all.ru/3.15/library/typing.html#special-types)
      - [Специальные формы](https://python-all.ru/3.15/library/typing.html#special-forms)
      - [Построение обобщённых типов и псевдонимов типов](https://python-all.ru/3.15/library/typing.html#building-generic-types-and-type-aliases)
      - [Другие специальные директивы](https://python-all.ru/3.15/library/typing.html#other-special-directives)
    - [Протоколы](https://python-all.ru/3.15/library/typing.html#protocols)
    - [ABC и протоколы для работы с вводом-выводом](https://python-all.ru/3.15/library/typing.html#abcs-and-protocols-for-working-with-i-o)
    - [Функции и декораторы](https://python-all.ru/3.15/library/typing.html#functions-and-decorators)
    - [Вспомогательные функции интроспекции](https://python-all.ru/3.15/library/typing.html#introspection-helpers)
    - [Константа](https://python-all.ru/3.15/library/typing.html#constant)
    - [Устаревшие псевдонимы](https://python-all.ru/3.15/library/typing.html#deprecated-aliases)

      - [Псевдонимы для встроенных типов](https://python-all.ru/3.15/library/typing.html#aliases-to-built-in-types)
      - [Псевдонимы для типов в `collections`](https://python-all.ru/3.15/library/typing.html#aliases-to-types-in-collections)
      - [Псевдонимы для других конкретных типов](https://python-all.ru/3.15/library/typing.html#aliases-to-other-concrete-types)
      - [Псевдонимы для ABC-контейнеров в `collections.abc`](https://python-all.ru/3.15/library/typing.html#aliases-to-container-abcs-in-collections-abc)
      - [Псевдонимы для асинхронных ABC в `collections.abc`](https://python-all.ru/3.15/library/typing.html#aliases-to-asynchronous-abcs-in-collections-abc)
      - [Псевдонимы для других ABC в `collections.abc`](https://python-all.ru/3.15/library/typing.html#aliases-to-other-abcs-in-collections-abc)
      - [Псевдонимы для `contextlib`-ABC](https://python-all.ru/3.15/library/typing.html#aliases-to-contextlib-abcs)
  - [График устаревания основных возможностей](https://python-all.ru/3.15/library/typing.html#deprecation-timeline-of-major-features)
- [`pydoc` – генератор документации и система интерактивной справки](https://python-all.ru/3.15/library/pydoc.html)
- [Режим разработки Python](https://python-all.ru/3.15/library/devmode.html)

  - [Эффекты режима разработки Python](https://python-all.ru/3.15/library/devmode.html#effects-of-the-python-development-mode)
  - [Пример ResourceWarning](https://python-all.ru/3.15/library/devmode.html#resourcewarning-example)
  - [Пример ошибки с некорректным файловым дескриптором](https://python-all.ru/3.15/library/devmode.html#bad-file-descriptor-error-example)
- [`doctest` – тестирование интерактивных примеров Python](https://python-all.ru/3.15/library/doctest.html)

  - [Простое использование: проверка примеров в строках документации](https://python-all.ru/3.15/library/doctest.html#simple-usage-checking-examples-in-docstrings)
  - [Простое использование: проверка примеров в текстовом файле](https://python-all.ru/3.15/library/doctest.html#simple-usage-checking-examples-in-a-text-file)
  - [Использование из командной строки](https://python-all.ru/3.15/library/doctest.html#command-line-usage)
  - [Как это работает](https://python-all.ru/3.15/library/doctest.html#how-it-works)

    - [Какие строки документации проверяются?](https://python-all.ru/3.15/library/doctest.html#which-docstrings-are-examined)
    - [Как распознаются примеры в строках документации?](https://python-all.ru/3.15/library/doctest.html#how-are-docstring-examples-recognized)
    - [Каков контекст выполнения?](https://python-all.ru/3.15/library/doctest.html#what-s-the-execution-context)
    - [А как насчёт исключений?](https://python-all.ru/3.15/library/doctest.html#what-about-exceptions)
    - [Флаги опций](https://python-all.ru/3.15/library/doctest.html#option-flags)
    - [Директивы](https://python-all.ru/3.15/library/doctest.html#directives)
    - [Предупреждения](https://python-all.ru/3.15/library/doctest.html#warnings)
  - [Базовый API](https://python-all.ru/3.15/library/doctest.html#basic-api)
  - [API unittest](https://python-all.ru/3.15/library/doctest.html#unittest-api)
  - [Расширенный API](https://python-all.ru/3.15/library/doctest.html#advanced-api)

    - [Объекты DocTest](https://python-all.ru/3.15/library/doctest.html#doctest-objects)
    - [Объекты Example](https://python-all.ru/3.15/library/doctest.html#example-objects)
    - [Объекты DocTestFinder](https://python-all.ru/3.15/library/doctest.html#doctestfinder-objects)
    - [Объекты DocTestParser](https://python-all.ru/3.15/library/doctest.html#doctestparser-objects)
    - [Объекты TestResults](https://python-all.ru/3.15/library/doctest.html#testresults-objects)
    - [Объекты DocTestRunner](https://python-all.ru/3.15/library/doctest.html#doctestrunner-objects)
    - [Объекты OutputChecker](https://python-all.ru/3.15/library/doctest.html#outputchecker-objects)
  - [Отладка](https://python-all.ru/3.15/library/doctest.html#debugging)
  - [Soapbox](https://python-all.ru/3.15/library/doctest.html#soapbox)
- [`unittest` – фреймворк для модульного тестирования](https://python-all.ru/3.15/library/unittest.html)

  - [Простой пример](https://python-all.ru/3.15/library/unittest.html#basic-example)
  - [Интерфейс командной строки](https://python-all.ru/3.15/library/unittest.html#command-line-interface)

    - [Параметры командной строки](https://python-all.ru/3.15/library/unittest.html#command-line-options)
  - [Обнаружение тестов](https://python-all.ru/3.15/library/unittest.html#test-discovery)
  - [Организация тестового кода](https://python-all.ru/3.15/library/unittest.html#organizing-test-code)
  - [Повторное использование старого тестового кода](https://python-all.ru/3.15/library/unittest.html#re-using-old-test-code)
  - [Пропуск тестов и ожидаемые сбои](https://python-all.ru/3.15/library/unittest.html#skipping-tests-and-expected-failures)
  - [Различение итераций теста с помощью подтестов](https://python-all.ru/3.15/library/unittest.html#distinguishing-test-iterations-using-subtests)
  - [Классы и функции](https://python-all.ru/3.15/library/unittest.html#classes-and-functions)

    - [Тестовые случаи](https://python-all.ru/3.15/library/unittest.html#test-cases)
    - [Группировка тестов](https://python-all.ru/3.15/library/unittest.html#grouping-tests)
    - [Загрузка и запуск тестов](https://python-all.ru/3.15/library/unittest.html#loading-and-running-tests)

      - [Протокол load\_tests](https://python-all.ru/3.15/library/unittest.html#load-tests-protocol)
  - [Фикстуры классов и модулей](https://python-all.ru/3.15/library/unittest.html#class-and-module-fixtures)

    - [setUpClass и tearDownClass](https://python-all.ru/3.15/library/unittest.html#setupclass-and-teardownclass)
    - [setUpModule и tearDownModule](https://python-all.ru/3.15/library/unittest.html#setupmodule-and-teardownmodule)
  - [Обработка сигналов](https://python-all.ru/3.15/library/unittest.html#signal-handling)
- [`unittest.mock` – библиотека mock-объектов](https://python-all.ru/3.15/library/unittest.mock.html)

  - [Краткое руководство](https://python-all.ru/3.15/library/unittest.mock.html#quick-guide)
  - [Класс Mock](https://python-all.ru/3.15/library/unittest.mock.html#the-mock-class)

    - [Вызов](https://python-all.ru/3.15/library/unittest.mock.html#calling)
    - [Удаление атрибутов](https://python-all.ru/3.15/library/unittest.mock.html#deleting-attributes)
    - [Имена Mock и атрибут name](https://python-all.ru/3.15/library/unittest.mock.html#mock-names-and-the-name-attribute)
    - [Прикрепление моков в качестве атрибутов](https://python-all.ru/3.15/library/unittest.mock.html#attaching-mocks-as-attributes)
  - [Патчеры](https://python-all.ru/3.15/library/unittest.mock.html#the-patchers)

    - [patch](https://python-all.ru/3.15/library/unittest.mock.html#patch)
    - [patch.object](https://python-all.ru/3.15/library/unittest.mock.html#patch-object)
    - [patch.dict](https://python-all.ru/3.15/library/unittest.mock.html#patch-dict)
    - [patch.multiple](https://python-all.ru/3.15/library/unittest.mock.html#patch-multiple)
    - [Методы patch: start и stop](https://python-all.ru/3.15/library/unittest.mock.html#patch-methods-start-and-stop)
    - [patch встроенных объектов](https://python-all.ru/3.15/library/unittest.mock.html#patch-builtins)
    - [TEST\_PREFIX](https://python-all.ru/3.15/library/unittest.mock.html#test-prefix)
    - [Вложение декораторов patch](https://python-all.ru/3.15/library/unittest.mock.html#nesting-patch-decorators)
    - [Где применять patch](https://python-all.ru/3.15/library/unittest.mock.html#where-to-patch)
    - [Подмена дескрипторов и прокси-объектов](https://python-all.ru/3.15/library/unittest.mock.html#patching-descriptors-and-proxy-objects)
  - [MagicMock и поддержка магических методов](https://python-all.ru/3.15/library/unittest.mock.html#magicmock-and-magic-method-support)

    - [Мокирование магических методов](https://python-all.ru/3.15/library/unittest.mock.html#mocking-magic-methods)
    - [Magic Mock](https://python-all.ru/3.15/library/unittest.mock.html#magic-mock)
  - [Вспомогательные средства](https://python-all.ru/3.15/library/unittest.mock.html#helpers)

    - [sentinel](https://python-all.ru/3.15/library/unittest.mock.html#sentinel)
    - [DEFAULT](https://python-all.ru/3.15/library/unittest.mock.html#default)
    - [вызов](https://python-all.ru/3.15/library/unittest.mock.html#call)
    - [create\_autospec](https://python-all.ru/3.15/library/unittest.mock.html#create-autospec)
    - [ANY](https://python-all.ru/3.15/library/unittest.mock.html#any)
    - [FILTER\_DIR](https://python-all.ru/3.15/library/unittest.mock.html#filter-dir)
    - [mock\_open](https://python-all.ru/3.15/library/unittest.mock.html#mock-open)
    - [Автоспецификация](https://python-all.ru/3.15/library/unittest.mock.html#autospeccing)
    - [Запечатывание моков](https://python-all.ru/3.15/library/unittest.mock.html#sealing-mocks)
  - [Порядок приоритета `side_effect`, `return_value` и *wraps*](https://python-all.ru/3.15/library/unittest.mock.html#order-of-precedence-of-side-effect-return-value-and-wraps)
- [`unittest.mock` – начало работы](https://python-all.ru/3.15/library/unittest.mock-examples.html)

  - [Использование Mock](https://python-all.ru/3.15/library/unittest.mock-examples.html#using-mock)

    - [Методы подмены Mock](https://python-all.ru/3.15/library/unittest.mock-examples.html#mock-patching-methods)
    - [Mock для вызовов методов объекта](https://python-all.ru/3.15/library/unittest.mock-examples.html#mock-for-method-calls-on-an-object)
    - [Мокирование классов](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-classes)
    - [Именование моков](https://python-all.ru/3.15/library/unittest.mock-examples.html#naming-your-mocks)
    - [Отслеживание всех вызовов](https://python-all.ru/3.15/library/unittest.mock-examples.html#tracking-all-calls)
    - [Установка возвращаемых значений и атрибутов](https://python-all.ru/3.15/library/unittest.mock-examples.html#setting-return-values-and-attributes)
    - [Возбуждение исключений с помощью моков](https://python-all.ru/3.15/library/unittest.mock-examples.html#raising-exceptions-with-mocks)
    - [Функции побочного эффекта и итерируемые объекты](https://python-all.ru/3.15/library/unittest.mock-examples.html#side-effect-functions-and-iterables)
    - [Мокирование асинхронных итераторов](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-asynchronous-iterators)
    - [Мокирование асинхронного контекстного менеджера](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-asynchronous-context-manager)
    - [Создание мока из существующего объекта](https://python-all.ru/3.15/library/unittest.mock-examples.html#creating-a-mock-from-an-existing-object)
    - [Использование side\_effect для возврата содержимого каждого файла](https://python-all.ru/3.15/library/unittest.mock-examples.html#using-side-effect-to-return-per-file-content)
  - [Декораторы patch](https://python-all.ru/3.15/library/unittest.mock-examples.html#patch-decorators)
  - [Дополнительные примеры](https://python-all.ru/3.15/library/unittest.mock-examples.html#further-examples)

    - [Мокирование цепочек вызовов](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-chained-calls)
    - [Частичное мокирование](https://python-all.ru/3.15/library/unittest.mock-examples.html#partial-mocking)
    - [Мокирование метода-генератора](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-a-generator-method)
    - [Применение одного и того же patch к каждому тестовому методу](https://python-all.ru/3.15/library/unittest.mock-examples.html#applying-the-same-patch-to-every-test-method)
    - [Мокирование несвязанных методов](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-unbound-methods)
    - [Проверка множественных вызовов с помощью mock](https://python-all.ru/3.15/library/unittest.mock-examples.html#checking-multiple-calls-with-mock)
    - [Работа с изменяемыми аргументами](https://python-all.ru/3.15/library/unittest.mock-examples.html#coping-with-mutable-arguments)
    - [Вложенные патчи](https://python-all.ru/3.15/library/unittest.mock-examples.html#nesting-patches)
    - [Мокирование словаря с помощью MagicMock](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-a-dictionary-with-magicmock)
    - [Подклассы Mock и их атрибуты](https://python-all.ru/3.15/library/unittest.mock-examples.html#mock-subclasses-and-their-attributes)
    - [Мокирование импортов с помощью patch.dict](https://python-all.ru/3.15/library/unittest.mock-examples.html#mocking-imports-with-patch-dict)
    - [Отслеживание порядка вызовов и менее многословные утверждения о вызовах](https://python-all.ru/3.15/library/unittest.mock-examples.html#tracking-order-of-calls-and-less-verbose-call-assertions)
    - [Более сложное сопоставление аргументов](https://python-all.ru/3.15/library/unittest.mock-examples.html#more-complex-argument-matching)
- [`test` – Пакет регрессионных тестов для Python](https://python-all.ru/3.15/library/test.html)

  - [Написание модульных тестов для пакета `test`](https://python-all.ru/3.15/library/test.html#writing-unit-tests-for-the-test-package)
  - [Запуск тестов с помощью интерфейса командной строки](https://python-all.ru/3.15/library/test.html#module-test.regrtest)
- [`test.support` – Утилиты для набора тестов Python](https://python-all.ru/3.15/library/test.html#module-test.support)
- [`test.support.socket_helper` – Утилиты для тестирования сокетов](https://python-all.ru/3.15/library/test.html#module-test.support.socket_helper)
- [`test.support.script_helper` – Утилиты для тестов выполнения Python](https://python-all.ru/3.15/library/test.html#module-test.support.script_helper)
- [`test.support.bytecode_helper` – Вспомогательные инструменты для тестирования корректной генерации байт-кода](https://python-all.ru/3.15/library/test.html#module-test.support.bytecode_helper)
- [`test.support.threading_helper` – Утилиты для тестирования потоков](https://python-all.ru/3.15/library/test.html#module-test.support.threading_helper)
- [`test.support.os_helper` – Утилиты для тестирования ОС](https://python-all.ru/3.15/library/test.html#module-test.support.os_helper)
- [`test.support.import_helper` – утилиты для тестирования импорта](https://python-all.ru/3.15/library/test.html#module-test.support.import_helper)
- [`test.support.warnings_helper` – утилиты для тестирования предупреждений](https://python-all.ru/3.15/library/test.html#module-test.support.warnings_helper)
