remove dependence and implmented import_string
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user