本文整理汇总了Python中base.User.save方法的典型用法代码示例。如果您正苦于以下问题:Python User.save方法的具体用法?Python User.save怎么用?Python User.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.User
的用法示例。
在下文中一共展示了User.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_data
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import save [as 别名]
def init_data():
"""Fish data for project"""
db.drop_all()
db.create_all()
user = User(username='John Doe', email='[email protected]', password='test')
user.save()
示例2: init_data
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import save [as 别名]
def init_data():
"""Fish data for project"""
db.drop_all()
db.create_all()
admin = User(
username=app.config["ADMIN_USERNAME"], email=app.config["ADMIN_EMAIL"], password=app.config["ADMIN_PASSWORD"]
)
admin.save()
示例3: KitTestCase
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import save [as 别名]
class KitTestCase(TestCase):
def create_app(self):
return AppFactory(TestingConfig).get_app(__name__)
def setUp(self):
db.create_all()
self.user = User(username='John Doe', email='[email protected]', password='test')
self.user.save()
def tearDown(self):
db.session.remove()
db.drop_all()
def assertContains(self, response, text, count=None, status_code=200, msg_prefix=''):
"""
Asserts that a response indicates that some content was retrieved
successfully, (i.e., the HTTP status code was as expected), and that
``text`` occurs ``count`` times in the content of the response.
If ``count`` is None, the count doesn't matter - the assertion is true
if the text occurs at least once in the response.
"""
if msg_prefix:
msg_prefix += ": "
self.assertEqual(
response.status_code,
status_code,
msg_prefix + (
"Couldn't retrieve content: Response code was %d "
"(expected %wd)" % (response.status_code, status_code)
)
)
real_count = response.data.count(text.encode())
if count is not None:
self.assertEqual(
real_count,
count,
msg_prefix + (
"Found %d instances of '%s' in response "
"(expected %d)" % (real_count, text, count)
)
)
else:
self.assertTrue(
real_count != 0,
msg_prefix + "Couldn't find '%s' in response" % text
)