Browse Source

Fixed an error reporting bug with flask.Config.from_envvar

pull/142/head
Armin Ronacher 15 years ago
parent
commit
6cb0855e2d
  1. 7
      CHANGES
  2. 3
      flask.py
  3. 20
      tests/flask_tests.py

7
CHANGES

@ -8,6 +8,13 @@ Version 0.4
Release date to be announced, codename to be selected. Release date to be announced, codename to be selected.
Version 0.3.1
-------------
Bugfix release, released May 28th
- fixed a error reporting bug with :meth:`flask.Config.from_envvar`
Version 0.3 Version 0.3
----------- -----------

3
flask.py

@ -698,7 +698,8 @@ class Config(dict):
raise RuntimeError('The environment variable %r is not set ' raise RuntimeError('The environment variable %r is not set '
'and as such configuration could not be ' 'and as such configuration could not be '
'loaded. Set this variable and make it ' 'loaded. Set this variable and make it '
'point to a configuration file') 'point to a configuration file' %
variable_name)
self.from_pyfile(rv) self.from_pyfile(rv)
return True return True

20
tests/flask_tests.py

@ -717,6 +717,26 @@ class ConfigTestCase(unittest.TestCase):
app.config.from_object(Test) app.config.from_object(Test)
self.common_object_test(app) self.common_object_test(app)
def test_config_from_envvar(self):
import os
env = os.environ
try:
os.environ = {}
app = flask.Flask(__name__)
try:
app.config.from_envvar('FOO_SETTINGS')
except RuntimeError, e:
assert "'FOO_SETTINGS' is not set" in str(e)
else:
assert 0, 'expected exception'
not app.config.from_envvar('FOO_SETTINGS', silent=True)
os.environ = {'FOO_SETTINGS': 'flask_tests.py'}
assert app.config.from_envvar('FOO_SETTINGS')
self.common_object_test(app)
finally:
os.environ = env
def suite(): def suite():
from minitwit_tests import MiniTwitTestCase from minitwit_tests import MiniTwitTestCase

Loading…
Cancel
Save