test_dem.py 文件源码

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

项目:game-tools 作者: joshuaskelly 项目源码 文件源码
def test_dem(self):
        d0 = dem.Dem.open('./test_data/test.dem')
        d0.close()

        d0.save(self.buff)
        self.buff.seek(0)

        b = io.BufferedReader(self.buff)
        d1 = dem.Dem.open(b)

        self.assertEqual(d1.cd_track, '2', 'Cd track should be 2')
        self.assertEqual(len(d1.message_blocks), 168, 'The demo should have 168 message blocks')

        last_message_of_first_block = d1.message_blocks[0].messages[-1]

        self.assertTrue(isinstance(last_message_of_first_block, dem.SignOnNum), 'The last message of the first block should be a SignOnNum')
        self.assertEqual(last_message_of_first_block.sign_on, 1, 'Sign on value should be 1')
        self.assertTrue(isinstance(d1.message_blocks[-1].messages[0], dem.Disconnect), 'The last message should be a Disconnect')

        self.assertFalse(d1.fp.closed, 'File should be open')
        fp = d1.fp
        d1.close()
        self.assertTrue(fp.closed, 'File should be closed')
        self.assertIsNone(d1.fp, 'File pointer should be cleaned up')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号