Flask view testing: How do I prevent data from being saved to the database? Flask view testing: How do I prevent data from being saved to the database? flask flask

Flask view testing: How do I prevent data from being saved to the database?


Using test_client alongside flush and rollback is the right approach. What are your concerns about jsonify? I don't see the connection to your main question.

Perhaps your teardown rollback isn't being called as you'd like. Including an in-line rollback allows you to verify the state is clear as part of the test.

Here's a gist showing that this approach works. https://gist.github.com/bhtucker/58a90e59265a0994bf42a23921d69718

You should be able to simply run bash setup_and_test.sh in an environment with psql tools and proper python dependencies.