def cached_and_cgi(name, template_func, render):
    """Return 2 functions for testing template in cached and cgi modes."""
    _template = template_func()
    def test_cached():
        # reuse early created template
        render(_template)
    test_cached.__doc__ = "test_%s" % name
    def test_cgi():
        # create new template on each call
        render(template_func())
    test_cgi.__doc__ = "test_%s_cgi" % name
    return test_cached, test_cgi