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
|
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()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue