def setUp(self):
self.app = create_app()
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
# ??????
python类create_app()的实例源码
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
# ??????
def app():
"""Creates an app with test settings"""
app = create_app()
return app
def setUp(self):
self.app = create_app('comment')
self.app_context = self.app.app_context()
self.app_context.push()
db.init_app(self.app)
db.create_all()
table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
table_structs = copy.deepcopy(table_structs)
table_structs.pop('__tablename__')
self.proxy = CommentProxy([key for key, value in table_structs.items()])
def setUp(self):
self.app = create_app('comment')
self.app_context = self.app.app_context()
self.app_context.push()
db.init_app(self.app)
db.create_all()
table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
table_structs = copy.deepcopy(table_structs)
table_structs.pop('__tablename__')
self.proxy = CommentProxy([key for key, value in table_structs.items()])
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
Role.insert_roles()
self.client = self.app.test_client()
def send_email(recipient, subject, template, **kwargs):
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
with app.app_context():
msg = Message(
app.config['EMAIL_SUBJECT_PREFIX'] + ' ' + subject,
sender=app.config['EMAIL_SENDER'],
recipients=[recipient])
msg.body = render_template(template + '.txt', **kwargs)
msg.html = render_template(template + '.html', **kwargs)
mail.send(msg)
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()