djblets.testing.testrunners¶
-
class
TestRunner
(*args, **kwargs)[source]¶ Bases:
django.test.runner.DiscoverRunner
Test runner for standard Djblets-based projects.
This class provides all the common setup for settings, databases, and directories that are generally needed by Django projects using Djblets. Much of the behavior can be overridden by subclasses.
nose is used to run the test suites. The options can be configured through
nose_options
.This can be subclassed in order to set the settings for the test run, or it can be instantiated with those settings passed in as keyword arguments.
-
__init__
(*args, **kwargs)[source]¶ Initialize the test runner.
The caller can override any of the options otherwise defined on the class.
Parameters: - nose_options (list, optional) – A list of options used for nose. See
nose_options
. - test_packages (list, optional) – A list of Python package/module names to test. See
test_packages
. - needs_collect_static (bool, optional) – Whether or not
collectstatic
needs to be run before tests. Seeneeds_collect_static
.
- nose_options (list, optional) – A list of options used for nose. See
-
nose_options
= [u'-v', u'--match=^test', u'--with-id', u'--with-doctest', u'--doctest-extension=.txt'][source]¶ The options used for nose.
This is a list of command line arguments that would be passed to nosetests.
-
setup_test_environment
(*args, **kwargs)[source]¶ Set up an environment for the unit tests.
This will handle setting all the default settings for a Djblets-based project and will create the directory structure needed for the tests in a temp directory.
Subclasses can override this to provide additional setup logic.
This must be called before
run_tests()
.Parameters: - *args (tuple) – Additional positional arguments to pass to Django’s version of this method.
- **kwargs (dict) – Additional keyword arguments to pass to Django’s version of this method.
-
teardown_test_environment
(*args, **kwargs)[source]¶ Tear down the environment for the unit tests.
This will clean up the temp directory structure.It must be called after
run_tests()
.Parameters: - *args (tuple) – Additional positional arguments to pass to Django’s version of this method.
- **kwargs (dict) – Additional keyword arguments to pass to Django’s version of this method.
-
run_tests
(test_labels=[], argv=None, *args, **kwargs)[source]¶ Run the test suite.
Parameters: - test_labels (list of unicode, optional) – Specific tests to run.
- argv (list of unicode, optional) – Additional arguments for nose. If not specified, sys.argv is used.
- *args (tuple, unused) – Unused additional positional arguments.
- **kwargs (dict, unused) – Unused additional keyword arguments.
Returns: The exit code. 0 means all tests passed, while 1 means there were failures.
Return type:
-
setup_dirs
()[source]¶ Set up directories to create and use.
This can return one or more directory paths that need to be created before the tests can be run. It may also store settings pointing to those paths.
This is not responsible for creating the directories. Any returned paths will be created automatically.
Returns: A list of directory paths to create. Return type: list of unicode
-