Hello,
I am writing my first WEB application in Python 3.4 using Flask. I mainly rely on the book "Flask Web Development" by Miguel Greenberg (ISBN: 978-1-449-37262-0) and the official documentation on Flask.
Now I try to write the first tests using unittest.TestCase and there are a few things that are not clear to me:
- In Miguel’s book on page 76, where he has several configuration classes. Why did he introduce TestingConfig.TESTING, DevelopemntConfig.DEBUG? I did not see these constants used anywhere.
- Do I understand correctly that in order to send HTTP GET / POST and other requests to the application, I must receive a self.app.test_client () test client?
UPD :
- If item 2 says "yes", you need to get a test client, then this means that in each setUp () method I have to create an instanse Flask, i.e. "app = myapplication.create_app ('testing')" followed by getting the test.client self.app.test_client (). Wouldn't creating app with create_app () in each setUp () method slow down the tests?
Perhaps there are more correct ways to write unit tests. Then I ask the experienced to share knowledge
UPD:
In my application, I use the following approach for creating instance flask: Factories & Extensions . That is, using the create_app function (configName)