kiwicom / pytest-recording

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

How to overwrite/update YAML under cassettes? #37

Closed northtree closed 4 years ago

northtree commented 4 years ago

If the response is changed, how could I just update the specify test without manually remove YAML file?

Stranger6667 commented 4 years ago

Hello @northtree ! I think that at the moment --record-mode=new_episodes might work, but depends - old requests will be still in cassettes and it might be not needed.

We can add a new command-line flag to provide this behavior, for example --rewrite-cassettes - it will remove cassettes automatically before recording. What do you think?

northtree commented 4 years ago

@Stranger6667

I'm a little confused about --record-mode=new_episodes from VCR doc.

Record new interactions. Replay previously recorded interactions.

Is ^^ replay one (Step 2) the new recorded in this run (Step 1), or from previous run (aka from yaml)?

Stranger6667 commented 4 years ago

Is ^^ replay one (Step 2) the new recorded in this run (Step 1), or from previous run (aka from yaml)?

From the previous run, so the requests are not actually updated, only new ones are added

northtree commented 4 years ago

Is ^^ replay one (Step 2) the new recorded in this run (Step 1), or from previous run (aka from yaml)?

From the previous run, so the requests are not actually updated, only new ones are added

Thanks. I just wonder why VCR.py didn't provide overwrite mode, which is quite intuitive for beginner?

northtree commented 4 years ago

@Stranger6667 Another question not related to this issue: If the user doesn't provide any param for record-mode, what's the related mode in VCR.py will be used?

Stranger6667 commented 4 years ago

none will be used, as the safest default :)

Thanks. I just wonder why VCR.py didn't provide overwrite mode, which is quite intuitive for beginner?

We can either propose to add such mode there (it will be really convenient) or implement it here

northtree commented 4 years ago

none will be used, as the safest default :)

After installed pytest-recording, is there any option we could use to run tests without using VCR (aka accessing cassettes) ? I would like to have this option without manually comment out @pytest.mark.vcr for each test.

Stranger6667 commented 4 years ago

After installed pytest-recording, is there any option we could use to run tests without using VCR (aka accessing cassettes) ?

Yep, for example:

pytest -p no:recording

will disable VCR usage via this plugin completely

northtree commented 4 years ago
pytest -p no:recording

will disable VCR usage via this plugin completely

However, there will have PytestUnknownMarkWarning.

PytestUnknownMarkWarning: Unknown pytest.mark.vcr - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html