... ストの実行の仕方について説明します。 テストを書く ¶ Django のユニットテストには、Python スタンダードライブラリのモジュール、 unittest を使用します。このモジュールは、テストをクラスベースのアプローチで定義します。 次の例では、 unittest.TestCase のサブクラス ... と、テストユーティリティのデフォルトの動作として、ファイル名が test で始まるファイル内のすべてのテストケースクラス (つまり unittest.TestCase のサブクラス) を見つけ、それらのテストケースクラスから自動的にテストスイートを構築し、そのテストスイートを実行しま ... す。 unittest の詳細については、Python のドキュメントを読んでください。 どこにテストを書くべき? デフォルトの startapp テンプレートは、新 ... ... ストの実行の仕方について説明します。 テストを書く ¶ Django のユニットテストには、Python スタンダードライブラリのモジュール、 unittest を使用します。このモジュールは、テストをクラスベースのアプローチで定義します。 次の例では、 unittest.TestCase のサブクラス ... と、テストユーティリティのデフォルトの動作として、ファイル名が test で始まるファイル内のすべてのテストケースクラス (つまり unittest.TestCase のサブクラス) を見つけ、それらのテストケースクラスから自動的にテストスイートを構築し、そのテストスイートを実行しま ... す。 unittest の詳細については、Python のドキュメントを読んでください。 どこにテストを書くべき? デフォルトの startapp テンプレートは、新 ... ... Contrib support for easy handling of static files . Django's testing framework now supports (and ships with a copy of) the unittest2 library . Wherever possible, new features are introduced in a backwards-compatible manner per our API stability policy po ... e served at STATIC_URL . See the reference documentation of the app for more details or learn how to manage static files . unittest2 のサポート ¶ Python 2.7 では unittest ライブラリに大きな変更が加えられ、非常に便利な機能が追加されました。すべての Django ... クトがこれらの新機能の恩恵を受けられるように、Django には Python 2.4 との互換性を保つためにバックポートされた Python 2.7 の unittest ライブラリのコピーである unittest2 が同梱されています。 To access this library, Django provides the django.utils.unittest ... ... Contrib support for easy handling of static files . Django's testing framework now supports (and ships with a copy of) the unittest2 library . Wherever possible, new features are introduced in a backwards-compatible manner per our API stability policy po ... e served at STATIC_URL . See the reference documentation of the app for more details or learn how to manage static files . unittest2 のサポート ¶ Python 2.7 では unittest ライブラリに大きな変更が加えられ、非常に便利な機能が追加されました。すべての Django ... クトがこれらの新機能の恩恵を受けられるように、Django には Python 2.4 との互換性を保つためにバックポートされた Python 2.7 の unittest ライブラリのコピーである unittest2 が同梱されています。 To access this library, Django provides the django.utils.unittest ... ... 的にアクティブな言語をセットする にあります。 カスタマイズ例 ¶ 以下は、テストクライアントを使ったユニットテストです。 import unittest from django.test import Client class SimpleTest ( unittest . TestCase ): def setUp ( self ): # Every test needs a client. ... stomers" ]), 5 ) 参考 django.test.RequestFactory 提供されるテストケースのクラス ¶ 標準の Python ユニットテストのクラスは、 unittest.TestCase のベースクラスを拡張しています。Django は、このベースクラスのいくつかの拡張を提供します。 Django ユニットテストク ... ラスの階層 ¶ 通常の unittest.TestCase は、任意のサブクラスに変換できます。つまり、テストのベースクラスを unittest.TestCase からサブクラスに変更します。 ... ... 的にアクティブな言語をセットする にあります。 カスタマイズ例 ¶ 以下は、テストクライアントを使ったユニットテストです。 import unittest from django.test import Client class SimpleTest ( unittest . TestCase ): def setUp ( self ): # Every test needs a client. ... stomers" ]), 5 ) 参考 django.test.RequestFactory 提供されるテストケースのクラス ¶ 標準の Python ユニットテストのクラスは、 unittest.TestCase のベースクラスを拡張しています。Django は、このベースクラスのいくつかの拡張を提供します。 Django ユニットテストク ... ラスの階層 ¶ 通常の unittest.TestCase は、任意のサブクラスに変換できます。つまり、テストのベースクラスを unittest.TestCase からサブクラスに変更します。 ... ... tils.timezone , django.utils.timezone.get_default_timezone() and django.utils.timezone.get_fixed_timezone() . django.utils.unittest ¶ django.utils.unittest provided uniform access to the unittest2 library on all Python versions. Since unittest2 became th ... e standard library's unittest module in Python 2.7, and Django 1.7 drops support for older Python versions, this module isn't useful anymore. It has bee ... n deprecated. Use unittest instead. django.utils.datastructures.SortedDict ¶ As OrderedDict was added to the standard library in Python 2.7, SortedDi ... ... tils.timezone , django.utils.timezone.get_default_timezone() and django.utils.timezone.get_fixed_timezone() . django.utils.unittest ¶ django.utils.unittest provided uniform access to the unittest2 library on all Python versions. Since unittest2 became th ... e standard library's unittest module in Python 2.7, and Django 1.7 drops support for older Python versions, this module isn't useful anymore. It has bee ... n deprecated. Use unittest instead. django.utils.datastructures.SortedDict ¶ As OrderedDict was added to the standard library in Python 2.7, SortedDi ... ... るので、その models.py ファイルにテスト専用のモデルを定義することもできます。 ほかのテストフレームワークを使う ¶ 明らかに、 unittest は唯一のPythonテストフレームワークではありません。Djangoは代替フレームワークに対する明示的なサポートを提供していませんが、 ... 引数を使用できるようになります。 属性 ¶ DiscoverRunner. test_suite ¶ テストスイートのビルドに使用するクラス。デフォルトでは unittest.TestSuite に設定されています。テストを収集するために別のロジックを実装したい場合は、これをオーバーライドできます。 Discove ... r ¶ これは低レベルテストランナーのクラスで、個々のテストを実行し、結果をフォーマットするために使用されます。デフォルトでは unittest.TextTestRunner に設定されています。似たような名前になっていますが、残念ながらこれは DiscoverRunner と同じ種類のクラスではあ ... ... るので、その models.py ファイルにテスト専用のモデルを定義することもできます。 ほかのテストフレームワークを使う ¶ 明らかに、 unittest は唯一のPythonテストフレームワークではありません。Djangoは代替フレームワークに対する明示的なサポートを提供していませんが、 ... 引数を使用できるようになります。 属性 ¶ DiscoverRunner. test_suite ¶ テストスイートのビルドに使用するクラス。デフォルトでは unittest.TestSuite に設定されています。テストを収集するために別のロジックを実装したい場合は、これをオーバーライドできます。 Discove ... r ¶ これは低レベルテストランナーのクラスで、個々のテストを実行し、結果をフォーマットするために使用されます。デフォルトでは unittest.TextTestRunner に設定されています。似たような名前になっていますが、残念ながらこれは DiscoverRunner と同じ種類のクラスではあ ... 2026年10月08日