當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。