Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Delete casette if test fails when running with --record-mode=once #81

Open
dragonpaw opened this issue Apr 15, 2022 · 1 comment

Comments

@dragonpaw
Copy link

Is your feature request related to a problem? Please describe.
When I'm building a new test, I'll run the test with --record-mode=once, but the test might fail (since it's new) and I then have to go delete the file so it'll re-record. It's kinda an annoyance to go find and make sure I delete the right file.

Describe the solution you'd like
I'd love it if there was some logic where when running with --record-mode=once it only saved the files from the tests that pass, then I could write a bunch of new tests, run them all, the good ones would get saved, and then I'd go fix the ones that didn't pass.

Just kinda a nice to have I'd think. Definitely not a big issue. Though it seems odd to save a cassette for a failed test in general.

Describe alternatives you've considered
Considered --record-mode=any, but that would re-run unrelated tests that I'm not working on.

@CarloDePieri
Copy link

@dragonpaw I had this same problem some time ago; since I couldn't find any existing solution I wrote a pytest plugin that deletes cassettes of failed test by using a flexible decorator.
It does not depends on pytest-recording directly, but integrates nicely with it since it uses its same cassettes' default path. See if it suits your needs.

pytest-vcr-delete-on-fail

Also, folks of pytest-recording, you're more than welcome to take a look at the code, if this is a feature you recon would be interesting to have integrated in here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants