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


Python Student.delete方法代码示例

本文整理汇总了Python中students.models.Student.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Student.delete方法的具体用法?Python Student.delete怎么用?Python Student.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在students.models.Student的用法示例。


在下文中一共展示了Student.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_log_student_deleted_event

# 需要导入模块: from students.models import Student [as 别名]
# 或者: from students.models.Student import delete [as 别名]
    def test_log_student_deleted_event(self):
        """Check logging signals for deleted student"""
        student = Student(first_name='Demo', last_name='Student')
        student.save()

        # now override signal
        # add own root handler to catch student signals output
        out = StringIO()
        handler = logging.StreamHandler(out)
        logging.root.addHandler(handler)

        # delete existing student and check logger output
        sid = student.id
        student.delete()
        out.seek(0)
        self.assertEqual(out.readlines()[-1], 'Student Demo Student deleted (ID: %d)\n' % sid)

        # remove our handler from root logger
        logging.root.removeHandler(handler)
开发者ID:PyDev777,项目名称:studentsdb,代码行数:21,代码来源:test_signals.py

示例2: test_log_student_deleted_event

# 需要导入模块: from students.models import Student [as 别名]
# 或者: from students.models.Student import delete [as 别名]
    def test_log_student_deleted_event(self):
        """Check logging signal for deleted student"""
        # add own root handler to catch student signals output
        out = StringIO()
        handler = logging.StreamHandler(out)
        logging.root.addHandler(handler)

        # now create and delete student, this should raise new message inside
        # our logger output file
        student = Student(first_name='Demo', last_name='Student', ticket='123')
        student.save()
        student_id = student.id
        student.delete()

        # check output file content
        out.seek(0)
        self.assertEqual(out.readlines()[-1],
             'Student deleted: Demo Student (ID: %d)\n' % student_id)

        # remove our handler from root logger
        logging.root.removeHandler(handler)
开发者ID:dimadvk,项目名称:studentsdb,代码行数:23,代码来源:test_signals.py


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