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