'Unit/integration testing helper: register a renderer at
``path`` (usually a relative filename ala ``templates/foo.pt``
or an asset specification) and return the renderer object.
If the ``renderer`` argument is None, a \'dummy\' renderer will
be used.  This function is useful when testing code that calls
the :func:`pyramid.renderers.render` function or
:func:`pyramid.renderers.render_to_response` function or
any other ``render_*`` or ``get_*`` API of the
:mod:`pyramid.renderers` module.
Note that calling this method for with a ``path`` argument
representing a renderer factory type (e.g. for ``foo.pt``
usually implies the ``chameleon_zpt`` renderer factory)
clobbers any existing renderer factory registered for that
type.
.. note:: This method is also available under the alias
``testing_add_template`` (an older name for it).'

def testing_add_renderer(self, path, renderer=None):

    from pyramid.testing import DummyRendererFactory
    helper = RendererHelper(name=path, registry=self.registry)
    factory = self.registry.queryUtility(IRendererFactory, name=helper.type)
    if (not isinstance(factory, DummyRendererFactory)):
        factory = DummyRendererFactory(helper.type, factory)
        self.registry.registerUtility(factory, IRendererFactory, name=helper.type)
    from pyramid.testing import DummyTemplateRenderer
    if (renderer is None):
        renderer = DummyTemplateRenderer()
    factory.add(path, renderer)
    return renderer
