class FlaskWtfMacroTestBase(unittest.TestCase):
    """Test the flask-wtf -> govuk macros

    Test the output of passing flask-wtf form elements
    through the custom govuk macros, ensuring we get
    correctly formed responses."""

    def setup_method(self, method):
        self.app = app.test_client()
        app.jinja_env.lstrip_blocks = True
        app.jinja_env.trim_blocks = True

        app.config['WTF_CSRF_ENABLED'] = False

    def request(self, **kwargs):
        self.ctx = app.test_request_context('/', **kwargs)
        self.ctx.push()

        self.form = ExampleForm()
        self.form.validate_on_submit()

    def teardown_method(self, method):
        self.ctx.pop()

        app.config['WTF_CSRF_ENABLED'] = True

    def render(self, template):
        """Helper method to render a snippet of a form"""
        return render_template_string(template, form=self.form).strip()
    def request(self, **kwargs):
        self.ctx = app.test_request_context('/', **kwargs)
        self.ctx.push()

        self.form = ExampleForm()
        self.form.validate_on_submit()