7

I am testing a simple application I have made in flask (with the factory patter). Currently my test.py looks like this:

import unittest

from flask_react_app import create_app, db


class FlaskReactAppTests(unittest.TestCase):
    """
    Runs tests for python application.
    """
    def setUp(self):
        self.app = create_app('testing')
        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()
        db.create_all()

    def tearDown(self):
        db.drop_all()
        self.ctx.pop()

    def test_index_page(self):
        assert self.app.get("/") == 200

When I attempt to run this, I get an attribute error saying that:

AttributeError: 'Flask' object has no attribute 'get'

Is this because I should not be using the application to make requests? Or should I be using some sort of client?

davidism
  • 121,510
  • 29
  • 395
  • 339

0 Answers0