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
评论列表
文章目录