def test_invalid_config(self):
"""Test an existing configuration file but invalid"""
c = Config(base_dir + '/static/config_invalid.ini')
self.assertFalse(c.read())
self.assertGreater(len(c.errors), 0)
self.assertTrue('project_name' in c.errors)
self.assertEqual('Missing', c.errors['project_name'])
self.assertTrue('php.version' in c.errors)
self.assertEqual('the value "8.0" is unacceptable.', c.errors['php.version'])
# Don't go further with python < 3.5
try:
from contextlib import redirect_stderr
except Exception:
return
f = io.StringIO()
with redirect_stderr(f):
c.display_errors()
res = f.getvalue()
regex = re.compile('Failed validating .*config_invalid.ini', re.MULTILINE)
self.assertRegex(res, regex)
regex = re.compile('the value ".*8.0.*" is unacceptable', re.MULTILINE)
self.assertRegex(res, regex)
评论列表
文章目录