本文整理汇总了Python中models.Move.position_x方法的典型用法代码示例。如果您正苦于以下问题:Python Move.position_x方法的具体用法?Python Move.position_x怎么用?Python Move.position_x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Move
的用法示例。
在下文中一共展示了Move.position_x方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_positions
# 需要导入模块: from models import Move [as 别名]
# 或者: from models.Move import position_x [as 别名]
def test_invalid_positions(self):
''' Tests for positions outside of possible values.
Expected: Exception raised
'''
game = Game.objects.get(id=1)
player1 = Player.objects.get(id=1)
invalid_position = 7
move = Move(game=game, player=player1, position_x=invalid_position, position_y=1)
with self.assertRaises(IntegrityError) as context:
move.save()
self.assertEqual(context.exception.message, 'position_x, %s is outside of valid range,0-2' % invalid_position)
move.position_x = 0
move.position_y = invalid_position
with self.assertRaises(IntegrityError) as context:
move.save()
self.assertEqual(context.exception.message, 'position_y, %s is outside of valid range,0-2' % invalid_position)