Skip to content

Commit cfd3e50

Browse files
committed
use app.testing property instead of config
1 parent 07a7058 commit cfd3e50

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/testing.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In order to test the application, we add a second module
4141

4242
def setUp(self):
4343
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
44-
flaskr.app.config['TESTING'] = True
44+
flaskr.app.testing = True
4545
self.app = flaskr.app.test_client()
4646
with flaskr.app.app_context():
4747
flaskr.init_db()
@@ -98,8 +98,10 @@ test method to our class, like this::
9898

9999
def setUp(self):
100100
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
101+
flaskr.app.testing = True
101102
self.app = flaskr.app.test_client()
102-
flaskr.init_db()
103+
with flaskr.app.app_context():
104+
flaskr.init_db()
103105

104106
def tearDown(self):
105107
os.close(self.db_fd)
@@ -208,7 +210,7 @@ temporarily. With this you can access the :class:`~flask.request`,
208210
functions. Here is a full example that demonstrates this approach::
209211

210212
import flask
211-
213+
212214
app = flask.Flask(__name__)
213215

214216
with app.test_request_context('/?name=Peter'):

0 commit comments

Comments
 (0)