Undocumented
Function | setup_databases |
Create the test databases. |
Function | setup_test_environment |
Perform global pre-test setup, such as installing the instrumented template renderer and setting the email backend to the locmem email backend. |
Function | teardown_databases |
Destroy all the non-mirror databases. |
Function | teardown_test_environment |
Perform any global post-test teardown, such as restoring the original template renderer and restoring the email sending functions. |
Constant | TZ_SUPPORT |
Undocumented |
Variable | jinja2 |
Undocumented |
Variable | requires_tz_support |
Undocumented |
Class | _TestState |
Undocumented |
Class | Approximate |
Undocumented |
Class | CaptureQueriesContext |
Context manager that captures queries executed by the specified connection. |
Class | ContextList |
A wrapper that provides direct key access to context items contained in a list of context objects. |
Class | ignore_warnings |
Undocumented |
Class | isolate_apps |
Act as either a decorator or a context manager to register models defined in its wrapped context to an isolated registry. |
Class | LoggingCaptureMixin |
Capture the output from the 'django' logger and store it on the class's logger_output attribute. |
Class | modify_settings |
Like override_settings, but makes it possible to append, prepend, or remove items instead of redefining the entire list. |
Class | NullTimeKeeper |
Undocumented |
Class | override_script_prefix |
Decorator or context manager to temporary override the script prefix. |
Class | override_settings |
No summary |
Class | override_system_checks |
Act as a decorator. Override list of registered system checks. Useful when you override INSTALLED_APPS , e.g. if you exclude auth app, you also need to exclude its system checks. |
Class | TestContextDecorator |
A base class that can either be used as a context manager during tests or as a test function or unittest.TestCase subclass decorator to perform temporary alterations. |
Class | TimeKeeper |
Undocumented |
Function | captured_output |
Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream stream_name with a StringIO. |
Function | captured_stderr |
Capture the output of sys.stderr: |
Function | captured_stdin |
Capture the input to sys.stdin: |
Function | captured_stdout |
Capture the output of sys.stdout: |
Function | compare_xml |
No summary |
Function | dependency_ordered |
Reorder test_databases into an order that honors the dependencies described in TEST[DEPENDENCIES]. |
Function | extend_sys_path |
Context manager to temporarily add paths to sys.path. |
Function | freeze_time |
No summary |
Function | get_runner |
Undocumented |
Function | get_unique_databases_and_mirrors |
Figure out which databases actually need to be created. |
Function | instrumented_test_render |
An instrumented Template render method, providing a signal that can be intercepted by the test Client. |
Function | isolate_lru_cache |
Clear the cache of an LRU cache object on entering and exiting. |
Function | iter_test_cases |
Return an iterator over a test suite's unittest.TestCase objects. |
Function | register_lookup |
Context manager to temporarily register lookups on a model field using lookup_name (or the lookup's lookup_name if not provided). |
Function | require_jinja2 |
Decorator to enable a Jinja2 template engine in addition to the regular Django template engine for a test or skip it if Jinja2 isn't available. |
Function | tag |
Decorator to add tags to a test class or method. |
Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream stream_name with a StringIO.
Capture the output of sys.stderr:
- with captured_stderr() as stderr:
- print("hello", file=sys.stderr)
self.assertEqual(stderr.getvalue(), "hello
")
Capture the input to sys.stdin:
- with captured_stdin() as stdin:
- stdin.write('hello
stdin.seek(0) # call test code that consumes from sys.stdin captured = input()
self.assertEqual(captured, "hello")
Capture the output of sys.stdout:
- with captured_stdout() as stdout:
- print("hello")
self.assertEqual(stdout.getvalue(), "hello
")
Try to do a 'xml-comparison' of want and got. Plain string comparison doesn't always work because, for example, attribute ordering should not be important. Ignore comment nodes, processing instructions, document type node, and leading and trailing whitespaces.
Based on https://github.com/lxml/lxml/blob/master/src/lxml/doctestcompare.py
from time import time
) won't be affected
This isn't meant as a public API, but helps reduce some repetitive code in
Django's test suite.Figure out which databases actually need to be created.
Deduplicate entries in DATABASES that correspond the same database or are configured as test mirrors.
Return two values: - test_databases: ordered mapping of signatures to (name, list of aliases)
where all aliases share the same underlying database.
Return an iterator over a test suite's unittest.TestCase objects.
The tests argument can also be an iterable of TestCase objects.