kevin1024 / vcrpy

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

Route requests to different cassette files depending on host #676

Closed CaptainDriftwood closed 1 year ago

CaptainDriftwood commented 1 year ago

I have various hosts that I need to hit for a unit test. I'd like to be able to route the responses from each host to its own specific cassette file. The documentation does not appear to show an example of how to do this. Is there a recommended way of doing this?

kevin1024 commented 1 year ago

Check out the path_transformer and func_path_generator configuration vars.

They are not well documented but I believe they will do what you want.

https://vcrpy.readthedocs.io/en/latest/advanced.html?highlight=path_transformer#automatic-cassette-naming