Improved configuration support.
This commit is contained in:
parent
e84140aba2
commit
c4cac0abc1
3 changed files with 124 additions and 10 deletions
|
|
@ -27,6 +27,11 @@ sys.path.append(os.path.join(example_path, 'flaskr'))
|
|||
sys.path.append(os.path.join(example_path, 'minitwit'))
|
||||
|
||||
|
||||
# config keys used for the ConfigTestCase
|
||||
TEST_KEY = 'foo'
|
||||
SECRET_KEY = 'devkey'
|
||||
|
||||
|
||||
@contextmanager
|
||||
def catch_stderr():
|
||||
old_stderr = sys.stderr
|
||||
|
|
@ -669,6 +674,24 @@ class LoggingTestCase(unittest.TestCase):
|
|||
assert rv.data == 'Hello Server Error'
|
||||
|
||||
|
||||
class ConfigTestCase(unittest.TestCase):
|
||||
|
||||
def common_module_test(self, app):
|
||||
assert app.secret_key == 'devkey'
|
||||
assert app.config['test_key'] == 'foo'
|
||||
assert 'ConfigTestCase' not in app.config
|
||||
|
||||
def test_config_from_file(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.config.from_pyfile('flask_tests.py')
|
||||
self.common_module_test(app)
|
||||
|
||||
def test_config_from_module(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.config.from_module(__name__)
|
||||
self.common_module_test(app)
|
||||
|
||||
|
||||
def suite():
|
||||
from minitwit_tests import MiniTwitTestCase
|
||||
from flaskr_tests import FlaskrTestCase
|
||||
|
|
@ -679,6 +702,7 @@ def suite():
|
|||
suite.addTest(unittest.makeSuite(ModuleTestCase))
|
||||
suite.addTest(unittest.makeSuite(SendfileTestCase))
|
||||
suite.addTest(unittest.makeSuite(LoggingTestCase))
|
||||
suite.addTest(unittest.makeSuite(ConfigTestCase))
|
||||
if flask.json_available:
|
||||
suite.addTest(unittest.makeSuite(JSONTestCase))
|
||||
suite.addTest(unittest.makeSuite(MiniTwitTestCase))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue