test_cmd_line.py 文件源码

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

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_hash_randomization(self):
        # Verify that -R enables hash randomization:
        self.verify_valid_flag('-R')
        hashes = []
        for i in range(2):
            code = 'print(hash("spam"))'
            rc, out, err = assert_python_ok('-R', '-c', code)
            self.assertEqual(rc, 0)
            hashes.append(out)
        if check_impl_detail(pypy=False):  # PyPy does not really implement it!
            self.assertNotEqual(hashes[0], hashes[1])

        # Verify that sys.flags contains hash_randomization
        code = 'import sys; print("random is", sys.flags.hash_randomization)'
        rc, out, err = assert_python_ok('-R', '-c', code)
        self.assertEqual(rc, 0)
        self.assertIn(b'random is 1', out)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号