Skip to content
Myr

Improved error message for configuration files

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent ed1b34c · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • tests:+12 added−0 removed
  • other:+5 added−1 removed

2 files+17 added−1 removed

modified:flask/config.py+5 added-1 removed
114 unmodified lines
115 """116 filename = os.path.join(self.root_path, filename)117 d = type(sys)('config')118 d.__file__ = filename119 try:119 execfile(filename, d.__dict__)120 execfile(filename, d.__dict__)121 except IOError, e:122 e.strerror = 'Unable to load configuration file (%s)' % e.strerror123 raise124 self.from_object(d)125126 def from_object(self, obj):127 """Updates the values from the given object. An object can be of one
29 unmodified lines
modified:tests/flask_tests.py+12 added
1016 unmodified lines
1017 self.common_object_test(app)1018 finally:1019 os.environ = env10201021 def test_config_missing(self):1022 app = flask.Flask(__name__)1023 try:1024 app.config.from_pyfile('missing.cfg')1025 except IOError, e:1026 msg = str(e)1027 assert msg.startswith('[Errno 2] Unable to load configuration '1028 'file (No such file or directory):')1029 assert msg.endswith("missing.cfg'")1030 else:1031 assert 0, 'expected config'103210331034class SubdomainTestCase(unittest.TestCase):10351036 def test_basic_support(self):1037 app = flask.Flask(__name__)
154 unmodified lines