test_players.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:CatLaser2 作者: adafruit 项目源码 文件源码
def test_update_no_active_player_makes_next_active(self):
        # Setup, add some players to waiting list.
        laser_players = players.Players(1)
        laser_players.add_player('192.168.0.1')
        # Check none are yet active.
        self.assertEqual(None, laser_players.active_player())
        # Setup, create mock callbacks that will remember how they were called.
        start_active = unittest.mock.Mock()
        end_active = unittest.mock.Mock()
        # Call update with 1 second of time elapsed.
        laser_players.update(0.5, start_active, end_active)
        # Check start active was called with the first in line IP, and that the
        # currently active player is the first one added (with 1 second of playtime
        # left).
        start_active.assert_called_once_with('192.168.0.1')
        end_active.assert_not_called()
        self.assertEqual(('192.168.0.1', 1), laser_players.active_player())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号