in cassette/cassette_library.py [0:0]
def write_to_file(self):
"""Write mocked response to a directory of files."""
if not os.path.exists(self.filename):
os.mkdir(self.filename)
for cassette_name, response in self.data.items():
filename = self.generate_filename(cassette_name)
encoded_str = self.encoder.dump(response.to_dict())
with open(os.path.join(self.filename, filename), 'w') as f:
f.write(encoded_str)
# Update our hash
self.save_to_cache(file_hash=_hash(encoded_str), data=response)
self.is_dirty = False