Add Config.from_mapping

This commit is contained in:
Daniel Neuhäuser 2014-07-27 11:19:52 +02:00
parent 02f0c755a3
commit aa40b1731e
3 changed files with 51 additions and 0 deletions

View file

@ -47,6 +47,34 @@ class ConfigTestCase(FlaskTestCase):
app.config.from_json(os.path.join(current_dir, 'static', 'config.json'))
self.common_object_test(app)
def test_config_from_mapping(self):
app = flask.Flask(__name__)
app.config.from_mapping({
'SECRET_KEY': 'devkey',
'TEST_KEY': 'foo'
})
self.common_object_test(app)
app = flask.Flask(__name__)
app.config.from_mapping([
('SECRET_KEY', 'devkey'),
('TEST_KEY', 'foo')
])
self.common_object_test(app)
app = flask.Flask(__name__)
app.config.from_mapping(
SECRET_KEY='devkey',
TEST_KEY='foo'
)
self.common_object_test(app)
app = flask.Flask(__name__)
with self.assert_raises(TypeError):
app.config.from_mapping(
{}, {}
)
def test_config_from_class(self):
class Base(object):
TEST_KEY = 'foo'