|
|
@ -41,7 +41,7 @@ In order to test the application, we add a second module |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
def setUp(self): |
|
|
|
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp() |
|
|
|
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp() |
|
|
|
flaskr.app.config['TESTING'] = True |
|
|
|
flaskr.app.testing = True |
|
|
|
self.app = flaskr.app.test_client() |
|
|
|
self.app = flaskr.app.test_client() |
|
|
|
with flaskr.app.app_context(): |
|
|
|
with flaskr.app.app_context(): |
|
|
|
flaskr.init_db() |
|
|
|
flaskr.init_db() |
|
|
@ -98,7 +98,7 @@ test method to our class, like this:: |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
def setUp(self): |
|
|
|
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp() |
|
|
|
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp() |
|
|
|
flaskr.app.config['TESTING'] = True |
|
|
|
flaskr.app.testing = True |
|
|
|
self.app = flaskr.app.test_client() |
|
|
|
self.app = flaskr.app.test_client() |
|
|
|
with flaskr.app.app_context(): |
|
|
|
with flaskr.app.app_context(): |
|
|
|
flaskr.init_db() |
|
|
|
flaskr.init_db() |
|
|
@ -210,7 +210,7 @@ temporarily. With this you can access the :class:`~flask.request`, |
|
|
|
functions. Here is a full example that demonstrates this approach:: |
|
|
|
functions. Here is a full example that demonstrates this approach:: |
|
|
|
|
|
|
|
|
|
|
|
import flask |
|
|
|
import flask |
|
|
|
|
|
|
|
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
|
|
|
|
|
|
|
with app.test_request_context('/?name=Peter'): |
|
|
|
with app.test_request_context('/?name=Peter'): |
|
|
|