... and asynchronous test clients via the client and async_client attributes. データベースクエリを作る手薄との場合、サブクラス TransactionTestCase や TestCase を使用してください。 SimpleTestCase. databases SimpleTestCase はデフォルトでデータベースクエリを許可しません。 ... st などの例外を意図的に発生させたい場合は、この問題を避けるために、必ず super() を呼び出す前に実行するようにしてください。 TransactionTestCase class TransactionTestCase [ソース] TransactionTestCase は SimpleTestCase を継承し、以下のようなデータベースに特有の機能を追 ... 機能をもとにしたスキップ 。 それ以外の特別な assert* メソッド。 Django's TestCase class is a more commonly used subclass of TransactionTestCase that makes use of database transaction facilities to speed up the process of resetting the database to a known state at th ... ... ed in the execution of tests that might be backward-incompatible for some testing setups: Database flushing in django.test.TransactionTestCase Previously, the test database was truncated before each test run in a TransactionTestCase . In order to be able to run uni ... t tests in any order and to make sure they are always isolated from each other, TransactionTestCase will now reset the database after each test run instead. No more implicit DB sequences reset TransactionTestCase tests use ... the database flushing actions described above. This has been changed so no sequences are implicitly reset. This can cause TransactionTestCase tests that depend on hardcoded primary key values to break. The new reset_sequences attribute can be used to force the old ... ... でデータの複製が行われていることが原因ではありません。これはトランザクションに依存しているので、テストでは TestCase ではなく TransactionTestCase を使う必要があります。 テストデータベースの作成順をコントロールする デフォルトでは、 Django は全てのデータベースが default ... が作成され、最後に spades が作成されます。 DEPENDENCIES の定義に循環依存がある場合、 ImproperlyConfigured 例外が発生します。 TransactionTestCase の高度な機能 TransactionTestCase. available_apps 警告 この属性はプライベートAPIです。例えば、アプリケーションの読み込みの変 ... にアプリケーションのリストを指定すると、 Django はこれらのアプリケーションのモデルだけが利用可能であるかのように動作します。 TransactionTestCase の動作は以下のように変わります: post_migrate は、利用可能なアプリケーションの各モデルに対して、存在しない場合にコンテンツタ ... ... bAdmin ( BaseAdmin ): actions = BaseAdmin . actions + [ "b" ] django.contrib.gis Support for GDAL 1.9 and 1.10 is dropped. TransactionTestCase serialized data loading Initial data migrations are now loaded in TransactionTestCase at the end of the test, after the da ... was empty at the end of the whole test suite). This change shouldn't have an impact on your tests unless you've customized TransactionTestCase 's internals. sqlparse is required dependency Django のデータベース処理の一部をシンプルにするため、 sqlparse 0.2.2+ との依 ... it. Support for overrides that don't accept it will be removed in Django 3.1. The SimpleTestCase.allow_database_queries , TransactionTestCase.multi_db , and TestCase.multi_db attributes are deprecated in favor of SimpleTestCase.databases , TransactionTestCase.data ... ... クラスが最初に実行されます。 そして、他のすべての Django ベースのテスト ( SimpleTestCase をベースとしたテストケースクラス、 TransactionTestCase を含む) が、特定の順序を保証も強制もしない状態で実行されます。 最後に、その他の unittest.TestCase テスト (doctests を含む) ... あることもあります。 注釈 この新しいテスト順序は、テストケース順序の予期しない依存関係を明らかにするかもしれません。これは、 TransactionTestCase によってデータベース内に記述された宣言に依存する doctests のケースで、これらは独立的に実行できるように修正する必要がありま ... ちます。 ロールバックのエミュレーション マイグレーションで呼び出されるあらゆる初期データは、 TestCase テスト内のみで有効で、 TransactionTestCase 内では無効です。加えて、トランザクションがサポートされるバックエンドのみで有効です (最も重要な例外は MyISAM です)。これは、 ... ... using the test --buffer option. DiscoverRunner now skips running the system checks on databases not referenced by tests . TransactionTestCase teardown is now faster on MySQL due to flush command improvements. As a side effect the latter doesn't automatically reset ... sequences on teardown anymore. Enable TransactionTestCase.reset_sequences if your tests require this feature. URL Path converters can now raise ValueError in to_url() to indicate n ... ure_user() method requires request as the first positional argument. Support for SimpleTestCase.allow_database_queries and TransactionTestCase.multi_db is removed. ... ... ack functions passed to transaction.on_commit() in a list. This allows you to test such callbacks without using the slower TransactionTestCase . TransactionTestCase.assertQuerysetEqual() now supports direct comparison against another queryset rather than being rest ... now automatic AppConfig discovery. See Django 3.2 の新機能 for more details. Automatically calling repr() on a queryset in TransactionTestCase.assertQuerysetEqual() , when compared to string values, is deprecated. If you need the previous behavior, explicitly set t ... ... rely on invalid assumptions about the test environment, or if they require a specific test case ordering. For these cases, TransactionTestCase can be used instead. This is a just a quick fix to get around test case errors revealed by the new rollback approach; in t ... ting the database. This results in an immense speedup for most types of unit tests. See the documentation for TestCase and TransactionTestCase for a full description, and some important notes on database support. Test client improvements A couple of small -- but hi ... ... e has never completely worked as advertised. When using database backends that don't support transactions, or when using a TransactionTestCase, data that has been inserted using custom SQL will not be visible during the testing process. Unfortunately, there was no ... ... メソッド) assertNotContains() (SimpleTestCase のメソッド) assertNotInHTML() (SimpleTestCase のメソッド) assertNumQueries() (TransactionTestCase のメソッド) assertQuerySetEqual() (TransactionTestCase のメソッド) assertRaisesMessage() (SimpleTestCase のメソッド) asser ... discover() (django.contrib.admin モジュール) autoescape template tag AutoField (django.db.models のクラス) available_apps (TransactionTestCase の属性) avalues() (backends.base.SessionBase のメソッド) Avg (django.db.models のクラス) Azimuth (django.contrib.gis.db.mo ... ZONE setting DATABASE_ROUTERS setting DatabaseError DATABASES setting databases (SimpleTestCase の属性) (TestCase の属性) (TransactionTestCase の属性) DataError DATAFILE setting DATAFILE_EXTSIZE setting DATAFILE_MAXSIZE setting DATAFILE_SIZE setting DATAFILE_TMP se ... 2026年10月08日