vcr_test_base.py 文件源码

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

项目:azure-cli 作者: Azure 项目源码 文件源码
def _post_recording_scrub(self):
        """ Perform post-recording cleanup on the YAML file that can't be accomplished with the
        VCR recording hooks. """
        src_path = self.cassette_path
        rg_name = getattr(self, 'resource_group', None)
        rg_original = getattr(self, 'resource_group_original', None)

        t = tempfile.NamedTemporaryFile('r+')
        with open(src_path, 'r') as f:
            for line in f:
                # scrub resource group names
                if rg_original and rg_name != rg_original:
                    line = line.replace(rg_name, rg_original)
                # omit bearer tokens
                if 'authorization:' not in line.lower():
                    t.write(line)
        t.seek(0)
        with open(src_path, 'w') as f:
            for line in t:
                f.write(line)
        t.close()

    # COMMAND METHODS
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号