development.md
1> **Источник:** https://python-all.ru/3.3/library/development.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# 26. Инструменты разработки89Модули, описанные в этой главе, помогают разрабатывать программное обеспечение. Например, модуль [`pydoc`](https://python-all.ru/3.3/library/pydoc.html#module-pydoc) принимает модуль и генерирует документацию на основе его содержимого. Модули [`doctest`](https://python-all.ru/3.3/library/doctest.html#module-doctest) и [`unittest`](https://python-all.ru/3.3/library/unittest.html#module-unittest) содержат фреймворки для написания модульных тестов, которые автоматически выполняют код и проверяют, что выводится ожидаемый результат. **2to3** может транслировать исходный код Python 2.x в корректный код Python 3.x.1011Список модулей, описанных в этой главе:1213- [26.1. `pydoc` – Генератор документации и встроенная справочная система](https://python-all.ru/3.3/library/pydoc.html)14- [26.2. `doctest` – Тестирование интерактивных примеров Python](https://python-all.ru/3.3/library/doctest.html)1516 - [26.2.1. Простое использование: проверка примеров в строках документации](https://python-all.ru/3.3/library/doctest.html#simple-usage-checking-examples-in-docstrings)17 - [26.2.2. Простое использование: проверка примеров в текстовом файле](https://python-all.ru/3.3/library/doctest.html#simple-usage-checking-examples-in-a-text-file)18 - [26.2.3. Как это работает](https://python-all.ru/3.3/library/doctest.html#how-it-works)1920 - [26.2.3.1. Какие строки документации проверяются?](https://python-all.ru/3.3/library/doctest.html#which-docstrings-are-examined)21 - [26.2.3.2. Как распознаются примеры в docstring?](https://python-all.ru/3.3/library/doctest.html#how-are-docstring-examples-recognized)22 - [26.2.3.3. Каков контекст выполнения?](https://python-all.ru/3.3/library/doctest.html#what-s-the-execution-context)23 - [26.2.3.4. Что насчёт исключений?](https://python-all.ru/3.3/library/doctest.html#what-about-exceptions)24 - [26.2.3.5. Флаги опций](https://python-all.ru/3.3/library/doctest.html#option-flags)25 - [26.2.3.6. Директивы](https://python-all.ru/3.3/library/doctest.html#directives)26 - [26.2.3.7. Предупреждения](https://python-all.ru/3.3/library/doctest.html#warnings)27 - [26.2.4. Базовый API](https://python-all.ru/3.3/library/doctest.html#basic-api)28 - [26.2.5. API модуля unittest](https://python-all.ru/3.3/library/doctest.html#unittest-api)29 - [26.2.6. Расширенный API](https://python-all.ru/3.3/library/doctest.html#advanced-api)3031 - [26.2.6.1. Объекты DocTest](https://python-all.ru/3.3/library/doctest.html#doctest-objects)32 - [26.2.6.2. Объекты Example](https://python-all.ru/3.3/library/doctest.html#example-objects)33 - [26.2.6.3. Объекты DocTestFinder](https://python-all.ru/3.3/library/doctest.html#doctestfinder-objects)34 - [26.2.6.4. Объекты DocTestParser](https://python-all.ru/3.3/library/doctest.html#doctestparser-objects)35 - [26.2.6.5. Объекты DocTestRunner](https://python-all.ru/3.3/library/doctest.html#doctestrunner-objects)36 - [26.2.6.6. Объекты OutputChecker](https://python-all.ru/3.3/library/doctest.html#outputchecker-objects)37 - [26.2.7. Отладка](https://python-all.ru/3.3/library/doctest.html#debugging)38 - [26.2.8. Трибуна](https://python-all.ru/3.3/library/doctest.html#soapbox)39- [26.3. `unittest` – Фреймворк для модульного тестирования](https://python-all.ru/3.3/library/unittest.html)4041 - [26.3.1. Базовый пример](https://python-all.ru/3.3/library/unittest.html#basic-example)42 - [26.3.2. Интерфейс командной строки](https://python-all.ru/3.3/library/unittest.html#command-line-interface)4344 - [26.3.2.1. Параметры командной строки](https://python-all.ru/3.3/library/unittest.html#command-line-options)45 - [26.3.3. Обнаружение тестов](https://python-all.ru/3.3/library/unittest.html#test-discovery)46 - [26.3.4. Организация тестового кода](https://python-all.ru/3.3/library/unittest.html#organizing-test-code)47 - [26.3.5. Повторное использование старого тестового кода](https://python-all.ru/3.3/library/unittest.html#re-using-old-test-code)48 - [26.3.6. Пропуск тестов и ожидаемые сбои](https://python-all.ru/3.3/library/unittest.html#skipping-tests-and-expected-failures)49 - [26.3.7. Классы и функции](https://python-all.ru/3.3/library/unittest.html#classes-and-functions)5051 - [26.3.7.1. Тестовые случаи](https://python-all.ru/3.3/library/unittest.html#test-cases)5253 - [26.3.7.1.1. Устаревшие псевдонимы](https://python-all.ru/3.3/library/unittest.html#deprecated-aliases)54 - [26.3.7.2. Группировка тестов](https://python-all.ru/3.3/library/unittest.html#grouping-tests)55 - [26.3.7.3. Загрузка и выполнение тестов](https://python-all.ru/3.3/library/unittest.html#loading-and-running-tests)5657 - [26.3.7.3.1. Протокол load\_tests](https://python-all.ru/3.3/library/unittest.html#load-tests-protocol)58 - [26.3.8. Фикстуры классов и модулей](https://python-all.ru/3.3/library/unittest.html#class-and-module-fixtures)5960 - [26.3.8.1. setUpClass и tearDownClass](https://python-all.ru/3.3/library/unittest.html#setupclass-and-teardownclass)61 - [26.3.8.2. setUpModule и tearDownModule](https://python-all.ru/3.3/library/unittest.html#setupmodule-and-teardownmodule)62 - [26.3.9. Обработка сигналов](https://python-all.ru/3.3/library/unittest.html#signal-handling)63- [26.4. `unittest.mock` – библиотека mock-объектов](https://python-all.ru/3.3/library/unittest.mock.html)6465 - [26.4.1. Краткое руководство](https://python-all.ru/3.3/library/unittest.mock.html#quick-guide)66 - [26.4.2. Класс Mock](https://python-all.ru/3.3/library/unittest.mock.html#the-mock-class)6768 - [26.4.2.1. Вызов](https://python-all.ru/3.3/library/unittest.mock.html#calling)69 - [26.4.2.2. Удаление атрибутов](https://python-all.ru/3.3/library/unittest.mock.html#deleting-attributes)70 - [26.4.2.3. Имена mock и атрибут name](https://python-all.ru/3.3/library/unittest.mock.html#mock-names-and-the-name-attribute)71 - [26.4.2.4. Прикрепление имитирующих объектов как атрибутов](https://python-all.ru/3.3/library/unittest.mock.html#attaching-mocks-as-attributes)72 - [26.4.3. Патчеры](https://python-all.ru/3.3/library/unittest.mock.html#the-patchers)7374 - [26.4.3.1. patch](https://python-all.ru/3.3/library/unittest.mock.html#patch)75 - [26.4.3.2. patch.object](https://python-all.ru/3.3/library/unittest.mock.html#patch-object)76 - [26.4.3.3. patch.dict](https://python-all.ru/3.3/library/unittest.mock.html#patch-dict)77 - [26.4.3.4. patch.multiple](https://python-all.ru/3.3/library/unittest.mock.html#patch-multiple)78 - [26.4.3.5. Методы patch: start и stop](https://python-all.ru/3.3/library/unittest.mock.html#patch-methods-start-and-stop)79 - [26.4.3.6. TEST\_PREFIX](https://python-all.ru/3.3/library/unittest.mock.html#test-prefix)80 - [26.4.3.7. Вложение декораторов patch](https://python-all.ru/3.3/library/unittest.mock.html#nesting-patch-decorators)81 - [26.4.3.8. Где выполнять patch](https://python-all.ru/3.3/library/unittest.mock.html#where-to-patch)82 - [26.4.3.9. Патчинг дескрипторов и прокси-объектов](https://python-all.ru/3.3/library/unittest.mock.html#patching-descriptors-and-proxy-objects)83 - [26.4.4. MagicMock и поддержка магических методов](https://python-all.ru/3.3/library/unittest.mock.html#magicmock-and-magic-method-support)8485 - [26.4.4.1. Имитация магических методов](https://python-all.ru/3.3/library/unittest.mock.html#mocking-magic-methods)86 - [26.4.4.2. Magic Mock](https://python-all.ru/3.3/library/unittest.mock.html#magic-mock)87 - [26.4.5. Вспомогательные объекты](https://python-all.ru/3.3/library/unittest.mock.html#helpers)8889 - [26.4.5.1. sentinel](https://python-all.ru/3.3/library/unittest.mock.html#sentinel)90 - [26.4.5.2. DEFAULT](https://python-all.ru/3.3/library/unittest.mock.html#default)91 - [26.4.5.3. call](https://python-all.ru/3.3/library/unittest.mock.html#call)92 - [26.4.5.4. create\_autospec](https://python-all.ru/3.3/library/unittest.mock.html#create-autospec)93 - [26.4.5.5. ANY](https://python-all.ru/3.3/library/unittest.mock.html#any)94 - [26.4.5.6. FILTER\_DIR](https://python-all.ru/3.3/library/unittest.mock.html#filter-dir)95 - [26.4.5.7. mock\_open](https://python-all.ru/3.3/library/unittest.mock.html#mock-open)96 - [26.4.5.8. Автоспецификация](https://python-all.ru/3.3/library/unittest.mock.html#autospeccing)97- [26.5. `unittest.mock` – начало работы](https://python-all.ru/3.3/library/unittest.mock-examples.html)9899 - [26.5.1. Использование Mock](https://python-all.ru/3.3/library/unittest.mock-examples.html#using-mock)100101 - [26.5.1.1. Подмена методов с помощью Mock](https://python-all.ru/3.3/library/unittest.mock-examples.html#mock-patching-methods)102 - [26.5.1.2. Mock для вызовов методов объекта](https://python-all.ru/3.3/library/unittest.mock-examples.html#mock-for-method-calls-on-an-object)103 - [26.5.1.3. Подмена классов](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-classes)104 - [26.5.1.4. Именование имитирующих объектов](https://python-all.ru/3.3/library/unittest.mock-examples.html#naming-your-mocks)105 - [26.5.1.5. Отслеживание всех вызовов](https://python-all.ru/3.3/library/unittest.mock-examples.html#tracking-all-calls)106 - [26.5.1.6. Установка возвращаемых значений и атрибутов](https://python-all.ru/3.3/library/unittest.mock-examples.html#setting-return-values-and-attributes)107 - [26.5.1.7. Генерация исключений с помощью имитирующих объектов](https://python-all.ru/3.3/library/unittest.mock-examples.html#raising-exceptions-with-mocks)108 - [26.5.1.8. Функции и итерируемые объекты для побочных эффектов](https://python-all.ru/3.3/library/unittest.mock-examples.html#side-effect-functions-and-iterables)109 - [26.5.1.9. Создание Mock из существующего объекта](https://python-all.ru/3.3/library/unittest.mock-examples.html#creating-a-mock-from-an-existing-object)110 - [26.5.2. Декораторы подмены](https://python-all.ru/3.3/library/unittest.mock-examples.html#patch-decorators)111 - [26.5.3. Дополнительные примеры](https://python-all.ru/3.3/library/unittest.mock-examples.html#further-examples)112113 - [26.5.3.1. Подмена цепочечных вызовов](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-chained-calls)114 - [26.5.3.2. Частичная подмена](https://python-all.ru/3.3/library/unittest.mock-examples.html#partial-mocking)115 - [26.5.3.3. Подмена метода-генератора](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-a-generator-method)116 - [26.5.3.4. Применение одной и той же подмены к каждому тестовому методу](https://python-all.ru/3.3/library/unittest.mock-examples.html#applying-the-same-patch-to-every-test-method)117 - [26.5.3.5. Подмена несвязанных методов](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-unbound-methods)118 - [26.5.3.6. Проверка нескольких вызовов с помощью mock](https://python-all.ru/3.3/library/unittest.mock-examples.html#checking-multiple-calls-with-mock)119 - [26.5.3.7. Работа с изменяемыми аргументами](https://python-all.ru/3.3/library/unittest.mock-examples.html#coping-with-mutable-arguments)120 - [26.5.3.8. Вложение подмен](https://python-all.ru/3.3/library/unittest.mock-examples.html#nesting-patches)121 - [26.5.3.9. Подмена словаря с помощью MagicMock](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-a-dictionary-with-magicmock)122 - [26.5.3.10. Подклассы Mock и их атрибуты](https://python-all.ru/3.3/library/unittest.mock-examples.html#mock-subclasses-and-their-attributes)123 - [26.5.3.11. Подмена импортов с помощью patch.dict](https://python-all.ru/3.3/library/unittest.mock-examples.html#mocking-imports-with-patch-dict)124 - [26.5.3.12. Отслеживание порядка вызовов и компактные проверки вызовов](https://python-all.ru/3.3/library/unittest.mock-examples.html#tracking-order-of-calls-and-less-verbose-call-assertions)125 - [26.5.3.13. Более сложное сопоставление аргументов](https://python-all.ru/3.3/library/unittest.mock-examples.html#more-complex-argument-matching)126- [26.6. 2to3 – автоматическое преобразование кода Python 2 в 3](https://python-all.ru/3.3/library/2to3.html)127128 - [26.6.1. Использование 2to3](https://python-all.ru/3.3/library/2to3.html#using-2to3)129 - [26.6.2. Фиксаторы](https://python-all.ru/3.3/library/2to3.html#fixers)130 - [26.6.3. `lib2to3` - библиотека 2to3](https://python-all.ru/3.3/library/2to3.html#module-lib2to3)131- [26.7. `test` – пакет регрессионного тестирования для Python](https://python-all.ru/3.3/library/test.html)132133 - [26.7.1. Написание модульных тестов для пакета `test`](https://python-all.ru/3.3/library/test.html#writing-unit-tests-for-the-test-package)134 - [26.7.2. Запуск тестов через интерфейс командной строки](https://python-all.ru/3.3/library/test.html#running-tests-using-the-command-line-interface)135- [26.8. `test.support` – утилиты для набора тестов Python](https://python-all.ru/3.3/library/test.html#module-test.support)136- [26.9. `venv` – Создание виртуальных окружений](https://python-all.ru/3.3/library/venv.html)137138 - [26.9.1. Создание виртуальных окружений](https://python-all.ru/3.3/library/venv.html#creating-virtual-environments)139 - [26.9.2. API](https://python-all.ru/3.3/library/venv.html#api)140 - [26.9.3. Пример расширения `EnvBuilder`](https://python-all.ru/3.3/library/venv.html#an-example-of-extending-envbuilder)141