Flask Unit Testing - How To Reset App.url_map For Each Test?
I'm writing a series of unit tests for a Flask app. The setup for each test is as follows: Create a Flask app in testing mode (app.testing = True). Mount a test endpoint (route) o
Solution 1:
I could solve a similar problem by moving all stuff you instantiate for the setup into the setup (even the import of the libraries you are using there). Of course, this can be done in a more elegant way by having a create_app() method like you do for your whole flask application. The important point to take away here is to take the instance that keeps the state (here the endpoints) out of the global scope and move it into the create_app() method.
Tell me if you need more information on this.
Post a Comment for "Flask Unit Testing - How To Reset App.url_map For Each Test?"