def test_form(self):
        # test empty form
        with self.captured_templates(self.app) as templates:
            resp = self.client.post(self.url)
            self.assertStatus(resp, 200)
            template, context = templates[0]
            form = context['form']
            self.assertTrue(
                u'This field is required.' in form.errors['email']
            )

        # test validate email
        with self.captured_templates(self.app) as templates:
            resp = self.client.post(
                self.url,
                data=dict(email='user2@email.com')
            )
            self.assertStatus(resp, 200)
            template, context = templates[0]
            form = context['form']
            self.assertTrue(
                u'E-mail not found.' in form.errors['email']
            )

        # test valid form
        with mail.record_messages() as outbox:
            self.assertEquals(len(outbox), 0)
            resp = self.client.post(
                self.url,
                data=dict(email='user1@email.com')
            )
            self.assertRedirects(resp, self.redirect_to)
            self.assertEquals(len(outbox), 1)
            self.assertEquals(
                outbox[0].subject,
                u'Recover your password - Flask Example.'
            )

        # test valid form after redirect
        resp = self.client.post(
            self.url,
            data=dict(email='user1@email.com'),
            follow_redirects=True
        )
        self.assertStatus(resp, 200)
        self.assertTrue(
            resp.data in 'Check it out at your email instructions for setting a new password.'
        )
dataset/ETHPy150Open allisson/flask-example/accounts/tests/test_views.py/RecoverPasswordViewTest.test_form/swapped operands of `in`