Skip to content
Myr

Fix testing documentation to demonstrate using test client with teardown

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ultimecia7 · committed by ultimecia7 · parent 99660cc · Browse files · 1 file+5 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−6 removed

  • other:+5 added−6 removed

1 file+5 added−6 removed

modified:docs/testing.rst+5 added-6 removed
52 unmodified lines
53 @pytest.fixture54 def client():55 db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()56 flaskr.app.config['TESTING'] = True57 client = flaskr.app.test_client()57 58 with flaskr.app.test_client() as client:59 with flaskr.app.app_context():60 flaskr.init_db()61 yield client6259 with flaskr.app.app_context():60 flaskr.init_db()6162 yield client6363 os.close(db_fd)64 os.unlink(flaskr.app.config['DATABASE'])6566This client fixture will be called by each individual test. It gives us a
390 unmodified lines