-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved common fixtures into conftest.py
- Loading branch information
Joel Collins
committed
Apr 14, 2020
1 parent
dc58e20
commit c65aa71
Showing
3 changed files
with
62 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
from flask import Flask | ||
|
||
|
||
@pytest.fixture() | ||
def app(request): | ||
|
||
app = Flask(__name__) | ||
app.config["TESTING"] = True | ||
|
||
# pushes an application context manually | ||
ctx = app.app_context() | ||
ctx.push() | ||
|
||
# bind the test life with the context through the | ||
request.addfinalizer(ctx.pop) | ||
return app | ||
|
||
|
||
@pytest.fixture() | ||
def debug_app(request): | ||
|
||
app = Flask(__name__) | ||
app.config["TESTING"] = True | ||
app.debug = True | ||
|
||
# pushes an application context manually | ||
ctx = app.app_context() | ||
ctx.push() | ||
|
||
# bind the test life with the context through the | ||
request.addfinalizer(ctx.pop) | ||
return app | ||
|
||
|
||
@pytest.fixture() | ||
def app_ctx(app): | ||
with app.app_context(): | ||
yield app | ||
|
||
|
||
@pytest.fixture() | ||
def app_ctx_debug(debug_app): | ||
with debug_app.app_context(): | ||
yield debug_app | ||
|
||
|
||
@pytest.fixture | ||
def req_ctx(app): | ||
with app.test_request_context() as ctx: | ||
yield ctx | ||
|
||
|
||
@pytest.fixture | ||
def client(app): | ||
return app.test_client() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters