TestCase
Similar to TransactionTestCase, but use transaction.atomic() to achieve
test isolation.
Attributes
| Attribute | Type | Description |
|---|---|---|
| cls_atomics | dict | Dictionary mapping database names to their respective atomic transaction blocks opened at the class level for test isolation. |
| atomics | dict | Dictionary mapping database names to their respective atomic transaction blocks opened for an individual test method. |
Methods
setUpClass()
@classmethod
def setUpClass()
Prepares the class-level test environment by opening transactions, loading fixtures, and initializing test data.
tearDownClass()
@classmethod
def tearDownClass()
Cleans up the class-level test environment by rolling back transactions and closing database connections.
setUpTestData()
@classmethod
def setUpTestData()
Load initial data for the TestCase.
captureOnCommitCallbacks()
@classmethod
def captureOnCommitCallbacks(
using: str,
execute: bool
) - > list
Context manager to capture transaction.on_commit() callbacks.
Parameters
| Name | Type | Description |
|---|---|---|
| using | str | The database alias to monitor for on_commit callbacks |
| execute | bool | Whether to immediately invoke the captured callbacks upon exiting the context |
Returns
| Type | Description |
|---|---|
list | A list that will be populated with the captured callback functions |