test.SimpleTestCase.assertFormError()

SimpleTestCase.assertFormError(response, form, field, errors, msg_prefix='') [source] Asserts that a field on a form raises the provided list of errors when rendered on the form. form is the name the Form instance was given in the template context. field is the name of the field on the form to check. If field has a value of None, non-field errors (errors you can access via form.non_field_errors()) will be checked. errors is an error string, or a list of error strings, that are expected as a

test.SimpleTestCase.assertHTMLEqual()

SimpleTestCase.assertHTMLEqual(html1, html2, msg=None) [source] Asserts that the strings html1 and html2 are equal. The comparison is based on HTML semantics. The comparison takes following things into account: Whitespace before and after HTML tags is ignored. All types of whitespace are considered equivalent. All open tags are closed implicitly, e.g. when a surrounding tag is closed or the HTML document ends. Empty tags are equivalent to their self-closing version. The ordering of attribute

test.SimpleTestCase.assertFormsetError()

SimpleTestCase.assertFormsetError(response, formset, form_index, field, errors, msg_prefix='') [source] Asserts that the formset raises the provided list of errors when rendered. formset is the name the Formset instance was given in the template context. form_index is the number of the form within the Formset. If form_index has a value of None, non-form errors (errors you can access via formset.non_form_errors()) will be checked. field is the name of the field on the form to check. If field

test.SimpleTestCase.allow_database_queries

SimpleTestCase.allow_database_queries New in Django 1.9. SimpleTestCase disallows database queries by default. This helps to avoid executing write queries which will affect other tests since each SimpleTestCase test isn’t run in a transaction. If you aren’t concerned about this problem, you can disable this behavior by setting the allow_database_queries class attribute to True on your test class. Warning SimpleTestCase and its subclasses (e.g. TestCase, ...) rely on setUpClass() and tearD

test.SimpleTestCase.assertContains()

SimpleTestCase.assertContains(response, text, count=None, status_code=200, msg_prefix='', html=False) [source] Asserts that a Response instance produced the given status_code and that text appears in the content of the response. If count is provided, text must occur exactly count times in the response. Set html to True to handle text as HTML. The comparison with the response content will be based on HTML semantics instead of character-by-character equality. Whitespace is ignored in most case

test.runner.DiscoverRunner.test_suite

DiscoverRunner.test_suite The class used to build the test suite. By default it is set to unittest.TestSuite. This can be overridden if you wish to implement different logic for collecting tests.

test.runner.DiscoverRunner.test_runner

DiscoverRunner.test_runner This is the class of the low-level test runner which is used to execute the individual tests and format the results. By default it is set to unittest.TextTestRunner. Despite the unfortunate similarity in naming conventions, this is not the same type of class as DiscoverRunner, which covers a broader set of responsibilities. You can override this attribute to modify the way tests are run and reported.

test.SimpleTestCase

class SimpleTestCase [source] A subclass of unittest.TestCase that adds this functionality: Some useful assertions like:Checking that a callable raises a certain exception. Testing form field rendering and error treatment. Testing HTML responses for the presence/lack of a given fragment. Verifying that a template has/hasn't been used to generate a given response content. Verifying a HTTP redirect is performed by the app. Robustly testing two HTML fragments for equality/inequality or containm

test.runner.DiscoverRunner.teardown_databases()

DiscoverRunner.teardown_databases(old_config, **kwargs) Destroys the test databases, restoring pre-test conditions. old_config is a data structure defining the changes in the database configuration that need to be reversed. It is the return value of the setup_databases() method.

test.runner.DiscoverRunner.teardown_test_environment()

DiscoverRunner.teardown_test_environment(**kwargs) Restores the pre-test environment.