Merge pull request #1342 from hramezani/load_config_file_syntax_error

Handle syntax error in load config file.
This commit is contained in:
Stephen Sadowski
2018-10-11 08:56:48 -05:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from textwrap import dedent
import pytest
from sanic import Sanic
from sanic.exceptions import PyFileError
@contextmanager
@@ -87,6 +88,16 @@ def test_load_from_missing_envvar(app):
"could not be loaded.")
def test_load_config_from_file_invalid_syntax(app):
config = b"VALUE = some value"
with NamedTemporaryFile() as config_file:
config_file.write(config)
config_file.seek(0)
with pytest.raises(PyFileError):
app.config.from_pyfile(config_file.name)
def test_overwrite_exisiting_config(app):
app.config.DEFAULT = 1