kevin1024 / vcrpy

Automatically mock your HTTP interactions to simplify and speed up testing
MIT License
2.72k stars 388 forks source link

allow cassette operations without decorator #634

Open cfal opened 2 years ago

cfal commented 2 years ago

hi, i'm interested in using vcrpy for recording our http interactions across functions. right now it looks like all of the patching functionality can only be activated by CassetteContextDecorator, so we're doing the following:

def start_recording(self):
  self.cassette = Cassette.use(...)
  self.cassette.__enter__()

def stop_recording(self):
  self.cassette.__exit__()

this isn't a big deal, but was wondering whether it would it be possible to support this kind of pattern without relying on the context functions, or is there already a better way to do this?

thank you!