File tree 1 file changed +5
-3
lines changed 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ In order to test the application, we add a second module
41
41
42
42
def setUp(self):
43
43
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
44
- flaskr.app.config['TESTING'] = True
44
+ flaskr.app.testing = True
45
45
self.app = flaskr.app.test_client()
46
46
with flaskr.app.app_context():
47
47
flaskr.init_db()
@@ -98,8 +98,10 @@ test method to our class, like this::
98
98
99
99
def setUp(self):
100
100
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
101
+ flaskr.app.testing = True
101
102
self.app = flaskr.app.test_client()
102
- flaskr.init_db()
103
+ with flaskr.app.app_context():
104
+ flaskr.init_db()
103
105
104
106
def tearDown(self):
105
107
os.close(self.db_fd)
@@ -208,7 +210,7 @@ temporarily. With this you can access the :class:`~flask.request`,
208
210
functions. Here is a full example that demonstrates this approach::
209
211
210
212
import flask
211
-
213
+
212
214
app = flask.Flask(__name__)
213
215
214
216
with app.test_request_context('/?name=Peter'):
You can’t perform that action at this time.
0 commit comments