Handle config error in load config file.
This commit is contained in:
@@ -3,6 +3,7 @@ import pytest
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.exceptions import PyFileError
|
||||
|
||||
|
||||
def test_load_from_object(app):
|
||||
@@ -79,6 +80,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user