Update testing.rst

Share pytest fixtures to prevent duplicate initialization. 

See: https://docs.pytest.org/en/6.2.x/fixture.html#scope-sharing-fixtures-across-classes-modules-packages-or-session
This commit is contained in:
Mike Rossetti 2022-03-29 14:51:47 -04:00 committed by GitHub
parent 65b0eef303
commit 53d43465b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,7 +56,7 @@ set up and tear down resources.
import pytest import pytest
from my_project import create_app from my_project import create_app
@pytest.fixture() @pytest.fixture(scope="module")
def app(): def app():
app = create_app() app = create_app()
app.config.update({ app.config.update({
@ -70,12 +70,12 @@ set up and tear down resources.
# clean up / reset resources here # clean up / reset resources here
@pytest.fixture() @pytest.fixture(scope="module")
def client(app): def client(app):
return app.test_client() return app.test_client()
@pytest.fixture() @pytest.fixture(scope="module")
def runner(app): def runner(app):
return app.test_cli_runner() return app.test_cli_runner()