...

/

Pytest on Flask: Setting up the Flask App for Testing

Pytest on Flask: Setting up the Flask App for Testing

Get to know how to prepare a Flask application for testing.

Pytest on Flask

Testing Flask applications with pytest is trickier than testing the basic logic, because we can’t just call the application methods and have it work. A Flask application instance needs to be created first. There’s also the database to worry about. We need the server to access the database, but we also need to be sure we don’t mess up the real data. Generally, a separate testing database will make this possible. We’ll use pytest fixtures to handle both the Flask ...