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.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.assertFieldOutput()

SimpleTestCase.assertFieldOutput(fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='') [source] Asserts that a form field behaves correctly with various inputs. Parameters: fieldclass – the class of the field to be tested. valid – a dictionary mapping valid inputs to their expected cleaned values. invalid – a dictionary mapping invalid inputs to one or more raised error messages. field_args – the args passed to instantiate the field. field_kwargs – the kwargs

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.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

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.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.runner.DiscoverRunner.test_loader

DiscoverRunner.test_loader This is the class that loads tests, whether from TestCases or modules or otherwise and bundles them into test suites for the runner to execute. By default it is set to unittest.defaultTestLoader. You can override this attribute if your tests are going to be loaded in unusual ways.

test.runner.DiscoverRunner.teardown_test_environment()

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