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


Python User.remove_student方法代码示例

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


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

示例1: remove_student

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import remove_student [as 别名]
    def remove_student(self, other):
        """
        Removes the student from self.students and removes the edge for the graph connection

        :param other: Student to remove
        :type other: VisualUser
        :return: None
        """
        User.remove_student(self, other)
        for edge in other.edges:
            if edge.node1 == self.node and edge.node2 == other.node:
                other.edges.remove(edge)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:14,代码来源:visual_user.py

示例2: test_user_double_remove_student

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import remove_student [as 别名]
    def test_user_double_remove_student(self):
        """
        Tests that an error is raised when double removing a student
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_student(u2)
        u1.remove_student(u2)
        self.assertRaises(MissingStudentError, u1.remove_student, u2)

        self.assertEqual(len(u1.students), 0)
        self.assertFalse(u2 in u1.students)
        self.assertFalse(u1 in u2.coaches)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:15,代码来源:test_user.py

示例3: test_user_remove_single_student

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import remove_student [as 别名]
    def test_user_remove_single_student(self):
        """
        Tests removing a student from a user's students
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u1.add_student(u2)
        u1.remove_student(u2)

        self.assertEqual(len(u1.students), 0)
        self.assertFalse(u2 in u1.students)

        self.assertEqual(len(u2.coaches), 0)
        self.assertFalse(u1 in u2.coaches)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:16,代码来源:test_user.py

示例4: test_user_remove_multiple_students_same_name

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import remove_student [as 别名]
    def test_user_remove_multiple_students_same_name(self):
        """
        Tests removing students with the same name
        """
        u1 = User("u1", 1)
        u2 = User("u2", 1)
        u3 = User("u2", 1)
        u1.add_student(u2)
        u1.add_student(u3)

        u1.remove_student(u2)
        self.assertEqual(len(u1.students), 1)
        self.assertTrue(u3 in u1.students)
        self.assertFalse(u2 in u1.students)
        self.assertTrue(u1 in u3.coaches)
        self.assertFalse(u1 in u2.coaches)

        u1.remove_student(u3)
        self.assertEqual(len(u1.students), 0)
        self.assertFalse(u3 in u1.students)
        self.assertFalse(u2 in u1.students)
        self.assertFalse(u1 in u3.coaches)
        self.assertFalse(u1 in u2.coaches)
开发者ID:lemonade512,项目名称:KhanAcademyProject,代码行数:25,代码来源:test_user.py


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