remove dependence and implmented import_string

This commit is contained in:
Jotagê Sales
2018-12-26 21:19:54 -02:00
parent 19b304b0fc
commit a33ebbaf11
5 changed files with 25 additions and 4 deletions

View File

@@ -35,6 +35,11 @@ def test_load_from_object_string(app):
assert 'not_for_config' not in app.config
def test_load_from_object_string_exception(app):
with pytest.raises(ImportError):
app.config.from_object('test_config.Config.test')
def test_auto_load_env():
environ["SANIC_TEST_ANSWER"] = "42"
app = Sanic()

View File

@@ -1,4 +1,5 @@
from sanic import helpers
import pytest
def test_has_message_body():
@@ -72,3 +73,14 @@ def test_remove_entity_headers():
for header, expected in tests:
assert helpers.remove_entity_headers(header) == expected
def test_import_string():
from sanic.config import Config
obj = helpers.import_string('sanic.config.Config')
assert isinstance(obj, Config)
def test_import_string_exception():
with pytest.raises(ImportError):
helpers.import_string('test.test.test')