本文整理汇总了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)
示例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)