kiwicom / pytest-recording

A pytest plugin that allows recording network interactions via VCR.py
MIT License
425 stars 34 forks source link

How to check if a cassette is playing back? #102

Open ubalklen opened 1 year ago

ubalklen commented 1 year ago

I have a fixture and I want it to act differently depending on whether a cassete is playing back or not. Is there a way to check for this?

My first thought was to check the presence of a cassette with the same name of the running test, but I realized there are instances where there is a cassette but it's not playing back (for example, when --record-mode is rewrite or simply when the plugin is deactivated).

In case you're wondering why would I want do that, it's because my code makes some complex network requests using the pywin32 package that can't be done by requests. These requests won't be recorded and that's ok, but I don't want they being triggered when a cassette is playing back, so I intend to monkeypatch them but only in that case.