当前位置: 首页>>代码示例>>Python>>正文


Python User.save方法代码示例

本文整理汇总了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()
开发者ID:CoolCloud,项目名称:flask-kit,代码行数:9,代码来源:manage.py

示例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()
开发者ID:RockyRoad29,项目名称:flask-kit,代码行数:11,代码来源:manage.py

示例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
            )
开发者ID:semirook,项目名称:flask-kit,代码行数:52,代码来源:test_case.py


注:本文中的base.User.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。