本文整理匯總了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)