mirror of https://github.com/pallets/flask.git
Merge pull request #3240 from ultimecia7/docfix
Fix testing documentation to demonstrate using test client with teardown
This commit is contained in:
commit
6e995f2379
|
|
@ -54,12 +54,11 @@ the application for testing and initializes a new database::
|
|||
def client():
|
||||
db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
|
||||
flaskr.app.config['TESTING'] = True
|
||||
client = flaskr.app.test_client()
|
||||
|
||||
with flaskr.app.app_context():
|
||||
flaskr.init_db()
|
||||
|
||||
yield client
|
||||
|
||||
with flaskr.app.test_client() as client:
|
||||
with flaskr.app.app_context():
|
||||
flaskr.init_db()
|
||||
yield client
|
||||
|
||||
os.close(db_fd)
|
||||
os.unlink(flaskr.app.config['DATABASE'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue