Answer the question
In order to leave comments, you need to log in
How to do unit tests in Flask?
Hello everyone, I have an application in Flask. How can tests be organized for it, in which a test database would be created, which would be a copy of the production database (like in Django)?
Does this require Flask migrations?
PS In Flask I use alchemy as a form
Answer the question
In order to leave comments, you need to log in
1. Download Miguel's book. This is the Flask bible. Without her, as without hands!
2. I use flask-sqlalchemy , and create a base for tests using sqllite in memory
3. To access a client that can send requests to your web server, you can use client something like this:
class ApplicationTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app(config_name='testing')
self.app_ctx = self.app.app_context()
self.app_ctx.push()
db.create_all()
self.client = self.app.test_client()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question