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:
parent
65b0eef303
commit
53d43465b6
1 changed files with 3 additions and 3 deletions
|
|
@ -56,7 +56,7 @@ set up and tear down resources.
|
|||
import pytest
|
||||
from my_project import create_app
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture(scope="module")
|
||||
def app():
|
||||
app = create_app()
|
||||
app.config.update({
|
||||
|
|
@ -70,12 +70,12 @@ set up and tear down resources.
|
|||
# clean up / reset resources here
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture(scope="module")
|
||||
def client(app):
|
||||
return app.test_client()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture(scope="module")
|
||||
def runner(app):
|
||||
return app.test_cli_runner()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue