class documentation

class TestCase(TransactionTestCase):

View In Hierarchy

Similar to TransactionTestCase, but use transaction.atomic() to achieve test isolation.

In most situations, TestCase should be preferred to TransactionTestCase as it allows faster execution. However, there are some situations where using TransactionTestCase might be necessary (e.g. testing some transactional behavior).

On database backends with no transaction support, TestCase behaves as TransactionTestCase.

Class Method capture​On​Commit​Callbacks Context manager to capture transaction.on_commit() callbacks.
Class Method set​Up​Class Undocumented
Class Method set​Up​Test​Data Load initial data for the TestCase.
Class Method tear​Down​Class Undocumented
Class Method ​_databases​_support​_transactions Undocumented
Class Method ​_enter​_atomics Open atomic blocks for multiple databases.
Class Method ​_rollback​_atomics Rollback atomic blocks opened by the previous method.
Method ​_fixture​_setup Undocumented
Method ​_fixture​_teardown Undocumented
Method ​_should​_check​_constraints Undocumented
Method ​_should​_reload​_connections Undocumented
Instance Variable atomics Undocumented

Inherited from TransactionTestCase:

Class Method ​_databases​_names Undocumented
Method ​_post​_teardown No summary
Method ​_pre​_setup No summary
Method ​_reset​_sequences Undocumented
Method assert​Num​Queries Undocumented
Method assert​Queryset​Equal Undocumented
Class Variable ​_disallowed​_database​_msg Undocumented
Class Variable available​_apps Undocumented
Class Variable databases Undocumented
Class Variable fixtures Undocumented
Class Variable reset​_sequences Undocumented
Class Variable serialized​_rollback Undocumented

Inherited from SimpleTestCase (via TransactionTestCase):

Class Method ​_add​_databases​_failures Undocumented
Class Method ​_remove​_databases​_failures Undocumented
Class Method ​_validate​_databases Undocumented
Method __call__ Wrapper around default __call__ method to perform common Django test set up. This means that user-defined Test Cases aren't required to include a call to super().setUp().
Method ​_assert​_contains Undocumented
Method ​_assert​_raises​_or​_warns​_cm Undocumented
Method ​_assert​_template​_used Undocumented
Method _assert​Foo​Message Undocumented
Method ​_setup​_and​_call Perform the following in order: pre-setup, run test, post-teardown, skipping pre/post hooks if test is set to be skipped.
Method assert​Contains No summary
Method assert​Field​Output Assert that a form field behaves correctly with various inputs.
Method assert​Form​Error Assert that a form used to render the response has a specific field error.
Method assert​Formset​Error Assert that a formset used to render the response has a specific error.
Method assert​HTMLEqual Assert that two HTML snippets are semantically the same. Whitespace in most cases is ignored, and attribute ordering is not significant. The arguments must be valid HTML.
Method assert​HTMLNot​Equal Assert that two HTML snippets are not semantically equivalent.
Method assert​In​HTML Undocumented
Method assert​JSONEqual Assert that the JSON fragments raw and expected_data are equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
Method assert​JSONNot​Equal Assert that the JSON fragments raw and expected_data are not equal. Usual JSON non-significant whitespace rules apply as the heavyweight is delegated to the json library.
Method assert​No​Logs Assert no messages are logged on the logger, with at least the given level.
Method assert​Not​Contains Assert that a response indicates that some content was retrieved successfully, (i.e., the HTTP status code was as expected) and that text doesn't occur in the content of the response.
Method assert​Raises​Message Assert that expected_message is found in the message of a raised exception.
Method assert​Redirects Assert that a response redirected to a specific URL and that the redirect URL can be loaded.
Method assert​Template​Not​Used Assert that the template with the provided name was NOT used in rendering the response. Also usable as context manager.
Method assert​Template​Used Assert that the template with the provided name was used in rendering the response. Also usable as context manager.
Method assert​URLEqual Assert that two URLs are the same, ignoring the order of query string parameters except for parameters with the same name.
Method assert​Warns​Message Same as assertRaisesMessage but for assertWarns() instead of assertRaises().
Method assert​XMLEqual Assert that two XML snippets are semantically the same. Whitespace in most cases is ignored and attribute ordering is not significant. The arguments must be valid XML.
Method assert​XMLNot​Equal Assert that two XML snippets are not semantically equivalent. Whitespace in most cases is ignored and attribute ordering is not significant. The arguments must be valid XML.
Method debug Perform the same as __call__(), without catching the exception.
Method modify​_settings A context manager that temporarily applies changes a list setting and reverts back to the original value when exiting the context.
Method settings A context manager that temporarily sets a setting and reverts to the original value when exiting the context.
Class Variable ​_disallowed​_connection​_methods Undocumented
Class Variable ​_modified​_settings Undocumented
Class Variable ​_overridden​_settings Undocumented
Instance Variable async​_client Undocumented
Instance Variable client Undocumented
@classmethod
@contextmanager
def captureOnCommitCallbacks(cls, *, using=DEFAULT_DB_ALIAS, execute=False):
Context manager to capture transaction.on_commit() callbacks.
@classmethod
def setUpClass(cls):
@classmethod
def setUpTestData(cls):
Load initial data for the TestCase.
@classmethod
def tearDownClass(cls):

Undocumented

@classmethod
def _databases_support_transactions(cls):

Undocumented

@classmethod
def _enter_atomics(cls):
Open atomic blocks for multiple databases.
@classmethod
def _rollback_atomics(cls, atomics):
Rollback atomic blocks opened by the previous method.
def _fixture_setup(self):
def _fixture_teardown(self):
def _should_check_constraints(self, connection):

Undocumented

def _should_reload_connections(self):
atomics =

Undocumented