本文整理汇总了Python中user.User.add_opponent方法的典型用法代码示例。如果您正苦于以下问题:Python User.add_opponent方法的具体用法?Python User.add_opponent怎么用?Python User.add_opponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.add_opponent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cant_add_opponent_twice
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_cant_add_opponent_twice(self):
a = User()
b = User()
a.add_opponent(b)
self.assertEqual(1, a.opponents.__len__(), 'It should have only 1 opponent')
a.add_opponent(b)
self.assertEqual(1, a.opponents.__len__(), 'It should have only 1 opponent')
示例2: test_adds_opponents_both_ways
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_adds_opponents_both_ways(self):
a = User()
b = User()
self.assertEqual(0, a.opponents.__len__(), "done")
self.assertEqual(0, b.opponents.__len__(), "done")
a.add_opponent(b)
self.assertEqual(1, a.opponents.__len__(), "done")
self.assertEqual(1, b.opponents.__len__(), "done")
示例3: test_is_ready_to_leave
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_is_ready_to_leave(self):
a = User()
for number in range(0, 8):
b = User()
a.add_opponent(b)
self.assertFalse(a.is_ready_to_leave(), 'Should stay and did not')
for opponent in a.opponents:
opponent.idle = True
self.assertTrue(a.is_ready_to_leave(), 'Should be ready to leave')
示例4: test_can_add_opponent_exceeded
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_can_add_opponent_exceeded(self):
a = User()
for number in range(0,8):
b = User()
a.add_opponent(b)
self.assertEqual(8, a.opponents.__len__(), 'It does not have 8 oponents')
c = User()
a.add_opponent(c)
self.assertEqual(8, a.opponents.__len__(), 'It does not have 8 oponents')
self.assertEqual(0, c.opponents.__len__(), 'It does not have 8 oponents')
self.assertFalse(a.add_opponent(c), 'Does not return false on fail')
示例5: test_count_idle_opponents
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_count_idle_opponents(self):
a = User()
for number in range(0, 8):
b = User()
a.add_opponent(b)
self.assertEqual(0, a.count_idle_opponents(), 'Has idle opponents' )
a.opponents[2].idle = True
self.assertEqual(1, a.count_idle_opponents(), 'Has no idle opponents')
for opponent in a.opponents:
opponent.idle = True
self.assertEqual(8, a.count_idle_opponents(), 'Has no idle opponents')
示例6: test_can_add_opponent
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_can_add_opponent(self):
a = User()
for number in range(0,7):
b = User()
self.assertTrue(a.can_add_opponent(), 'Cannot add at sume number opponents')
a.add_opponent(b)
self.assertTrue(a.can_add_opponent(), 'Cannot add at 7 opponents')
self.assertEqual(7, a.opponents.__len__(), 'Does not have 7 opponents')
c = User()
a.add_opponent(c)
self.assertFalse(a.can_add_opponent(), 'Can add at 8 opponents')
示例7: test_cant_add_opponent_itself
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import add_opponent [as 别名]
def test_cant_add_opponent_itself(self):
a = User()
a.add_opponent(a)
self.assertEqual(0, a.opponents.__len__(), 'It should not have any opponents')