Creating an application without test cases is half done. Even though you take a lot of care while developing the application, there might be a chance of encountering errors at some point. Writing test cases will always leave us at a safe point.
In this section, we are going to write unit test cases for some tasks in our survey application. Add the following test case code to
import unittest import requests from bs4 import BeautifulSoup from survey import db from survey.models import Question class TestSurveyApp(unittest.TestCase): def setUp(self): db.drop_all() db.create_all() def test_defaults(self): question = Question('Are you from India?') db.session.add(question) db.session.commit() ...