Jump to >


Mixins for test cases that need to test enabled extensions.

class ExtensionTestCaseMixin[source]

Bases: object

Unit tests mixin for more easily testing extensions.

This will do the hard work of creating the fake registration information needed for an extension and to instantiate an instance for testing.

Subclasses need to define extension_class and may want to implement get_extension_manager() (by default, the first registered extension manager will be used).

Projects may want to provide their own subclass for their extensions to use that implements get_extension_manager(), so extensions won’t have to.


The extension manager owning the extension. Tests can use this to manually enable/disable the extension, if needed.


The extension instance being tested.

extension_class = None[source]

The extension class to test.

extension_metadata = {}[source]

Optional metadata to use for the extension information.

extension_package_name = u'TestPackage'[source]

Optional package name to use for the extension information.


Return the extension manager used for the tests.

Subclasses may want to override this to pick a specific extension manager, if the project uses more than one. The default behavior is to return the first registered extension manager.

Returns:The extension manager used for tests.
Return type:djblets.extensions.manager.ExtensionManager