Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Custom backends

Though tavern supports a few backends out of the box, you may want to extend it to support your own. This can be done by creating a new plugin that implements the necessary functionality and registers it with tavern.

First, write your backend and set up the request, response, etc as according to the standard plugin system. Note the standard restrictions - there can only be one ‘request’ per stage.

Entry Point Configuration

In your project’s pyproject.toml, configure the plugin entry point:

[project.entry-points.tavern_your_backend_name]
my_implementation = 'your.package.path:your_backend_module'

Then when running tests, specify the extra backend:

pytest --tavern-extra-backends=your_backend_name
# Or, to specify an implementation to override the project entrypoint:
pytest --tavern-extra-backends=your_backend_name=my_other_implementation

Or the equivalent in pyproject.toml or pytest.ini. Note:

This is because Tavern by default only tries to load “grpc”, “http” and “mqtt” backends. The flag registers the custom backend with Tavern, which can then tell stevedore to load the plugin from the entrypoint.