forked from orbit-oss/flask
reset standard os env after each test
This commit is contained in:
parent
f2cf4d0449
commit
8bdf820e9b
2 changed files with 43 additions and 18 deletions
|
|
@ -23,9 +23,11 @@ from _pytest.monkeypatch import notset
|
|||
from click.testing import CliRunner
|
||||
|
||||
from flask import Flask, current_app
|
||||
from flask.cli import AppGroup, FlaskGroup, NoAppException, ScriptInfo, dotenv, \
|
||||
find_best_app, get_version, load_dotenv, locate_app, prepare_import, \
|
||||
from flask.cli import (
|
||||
AppGroup, FlaskGroup, NoAppException, ScriptInfo, dotenv,
|
||||
find_best_app, get_version, load_dotenv, locate_app, prepare_import,
|
||||
with_appcontext
|
||||
)
|
||||
|
||||
cwd = os.getcwd()
|
||||
test_path = os.path.abspath(os.path.join(
|
||||
|
|
@ -33,19 +35,6 @@ test_path = os.path.abspath(os.path.join(
|
|||
))
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def manage_os_environ(monkeypatch):
|
||||
# can't use monkeypatch.delitem since we don't want to restore a value
|
||||
os.environ.pop('FLASK_APP', None)
|
||||
os.environ.pop('FLASK_DEBUG', None)
|
||||
# use monkeypatch internals to force-delete environ keys
|
||||
monkeypatch._setitem.extend((
|
||||
(os.environ, 'FLASK_APP', notset),
|
||||
(os.environ, 'FLASK_DEBUG', notset),
|
||||
(os.environ, 'FLASK_RUN_FROM_CLI', notset),
|
||||
))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner():
|
||||
return CliRunner()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue