ktosiek / pytest-vcr

Py.test integration with VCR.py
MIT License
154 stars 25 forks source link

Allow to specify custom cassette path per test. #25

Open svtkachenko opened 5 years ago

svtkachenko commented 5 years ago

Hi, please review if this change is valid and could be used.

Motivation for the change: I'd like to have default behavior for some tests (test_path/cassettes/test_name.yaml) but at the same time I'd like to reuse cassettes with same requests. It is not possible for me to store all tests in the same shared directory (e.g. by re-defining vcr_cassette_dir) as some tests can have same name but different location and different requests.

Stranger6667 commented 5 years ago

Hello @ktosiek ! Thank you for this library! It helps us a lot :) We'd be very grateful if customizing cassette name feature will be present in pytest-vcr. It could really help us to reduce duplicate/similar cassettes number (now we use vcr.use_cassette decorator to handle this). I hope, that these changes wouldn't take much of your time to review. 🍰

Have a nice day, Dmitry

neozenith commented 5 years ago

I have a PR accepted on VCRpy but am awaiting a release to PyPI officially

In the mean time, unofficially, you can use forks of these libraries by pip installing from github links if that helps.

https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch

Stranger6667 commented 5 years ago

Not sure if the mentioned MR is related to the problem with lacking support for custom test names.

The issue is solved here - https://github.com/kiwicom/pytest-recording

We decided to rewrite the whole pytest integration with awareness on #25 and #24. Also, it supports multiple cassettes (which reduces duplication dramatically in our case) and writes cassettes in different directories per test module to avoid clashing cassette names when there are the same test names in different test modules.