開発ツール
**********

The modules described in this chapter help you write software.  For
example, the "pydoc" module takes a module and generates documentation
based on the module's contents.  The "doctest" and "unittest" modules
contains frameworks for writing unit tests that automatically exercise
code and verify that the expected output is produced.  **2to3** can
translate Python 2.x source code into valid Python 3.x code.

この章で解説されるモジュールのリスト:

* "typing" --- 型ヒントのサポート

  * Relevant PEPs

  * 型エイリアス

  * NewType

  * 呼び出し可能オブジェクトのアノテーション

  * ジェネリクス

  * タプルのアノテーション

  * クラスオブジェクトの型

  * ユーザー定義のジェネリック型

  * "Any" 型

  * 名前的部分型 vs 構造的部分型

  * モジュールの内容

    * 特殊型付けプリミティブ

      * 特殊型

      * 特殊形式

      * Building generic types

      * Other special directives

    * プロトコル

    * ABCs for working with IO

    * Functions and decorators

    * Introspection helpers

    * 定数

    * 非推奨のエイリアス

      * Aliases to built-in types

      * Aliases to types in "collections"

      * Aliases to other concrete types

      * Aliases to container ABCs in "collections.abc"

      * Aliases to asynchronous ABCs in "collections.abc"

      * Aliases to other ABCs in "collections.abc"

      * Aliases to "contextlib" ABCs

  * メジャーな機能の非推奨時系列

* "pydoc" --- Documentation generator and online help system

* Python 開発モード

  * Effects of the Python Development Mode

  * ResourceWarning Example

  * Bad file descriptor error example

* "doctest" --- Test interactive Python examples

  * 簡単な利用法: docstring 中の実行例をチェックする

  * 簡単な利用法: テキストファイル中の実行例をチェックする

  * doctest のからくり

    * どの docstring が検証されるのか?

    * docstring 内の実行例をどのように認識するのか?

    * 実行コンテキストとは何か?

    * 例外はどう扱えばよいか?

    * オプションフラグ

    * ディレクティブ (Directives)

    * 警告

  * 基本 API

  * 単体テスト API

  * 拡張 API

    * DocTest オブジェクト

    * Example オブジェクト

    * DocTestFinder オブジェクト

    * DocTestParser オブジェクト

    * DocTestRunner オブジェクト

    * OutputChecker オブジェクト

  * デバッグ

  * アドバイス

* "unittest" --- Unit testing framework

  * 基本的な例

  * コマンドラインインターフェイス

    * コマンドラインオプション

  * テストディスカバリ

  * テストコードの構成

  * 既存テストコードの再利用

  * テストのスキップと予期された失敗

  * サブテストを利用して繰り返しテストの区別を付ける

  * クラスと関数

    * テストクラス

      * Deprecated aliases

    * テストのグループ化

    * テストのロードと起動

      * load_tests プロトコル

  * クラスとモジュールのフィクスチャ

    * setUpClass と tearDownClass

    * setUpModule と tearDownModule

  * シグナルハンドリング

* "unittest.mock" --- mock object library

  * クイックガイド

  * Mock クラス

    * 呼び出し

    * 属性の削除

    * Mock の名前と name 属性

    * 属性として設定されるモック

  * patcher

    * patch

    * patch.object

    * patch.dict

    * patch.multiple

    * patch のメソッド: start と stop

    * ビルトインをパッチする

    * TEST_PREFIX

    * patch デコレータをネストする

    * どこにパッチするか

    * デスクリプタやプロキシオブジェクトにパッチする

  * MagicMock と magic method のサポート

    * Magic Method をモックする

    * Magic Mock

  * ヘルパー

    * sentinel

    * DEFAULT

    * call

    * create_autospec

    * ANY

    * FILTER_DIR

    * mock_open

    * autospec を使う

    * Sealing mocks

  * Order of precedence of "side_effect", "return_value" and *wraps*

* "unittest.mock" --- getting started

  * Mock を使う

    * Mock のパッチ用メソッド

    * オブジェクトのメソッド呼び出しに対するモック

    * クラスをモックする

    * モックに名前をつける

    * 全ての呼び出しのトラッキング

    * 戻り値や属性を設定する

    * モックから例外を発生させる

    * side_effect の関数と iterable

    * 非同期イテレータをモックする

    * 非同期コンテキストマネージャをモックする

    * 既存のオブジェクトから Mock を作る

    * Using side_effect to return per file content

  * patch デコレータ

  * さらなる例

    * chained call をモックする

    * 部分的なモック

    * ジェネレータメソッドをモックする

    * 同じパッチを全てのメソッドに適用する

    * Unboundメソッドをモックする

    * モックで複数回の呼び出しをチェックする

    * ミュータブルな引数に対処する

    * patch をネストする

    * MagicMock で辞書をモックする

    * Mock のサブクラスと属性

    * patch.dict で import をモックする

    * Tracking order of calls and less verbose call assertions

    * More complex argument matching

* 2to3 --- Python 2 から 3 への自動コード変換

  * 2to3 の使用

  * 変換プログラム

  * "lib2to3" --- 2to3's library

* "test" --- Regression tests package for Python

  * "test" パッケージのためのユニットテストを書く

  * コマンドラインインターフェースを利用してテストを実行する

* "test.support" --- テストのためのユーティリティ関数

* "test.support.socket_helper" --- Utilities for socket tests

* "test.support.script_helper" --- Utilities for the Python execution
  tests

* "test.support.bytecode_helper" --- Support tools for testing correct
  bytecode generation

* "test.support.threading_helper" --- Utilities for threading tests

* "test.support.os_helper" --- Utilities for os tests

* "test.support.import_helper" --- Utilities for import tests

* "test.support.warnings_helper" --- Utilities for warnings tests
