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

[BUG] Default record_mode is 'none' instead of 'once' #66

Closed
paxcodes opened this issue Mar 12, 2021 · 4 comments
Closed

[BUG] Default record_mode is 'none' instead of 'once' #66

paxcodes opened this issue Mar 12, 2021 · 4 comments

Comments

@paxcodes
Copy link

Describe the bug
When I use the decorator without passing any record_mode (@pytest.mark.vcr), I get an error saying,

vcr.errors.CannotOverwriteExistingCassetteException: Can't overwrite existing cassette ('/path/test_single.yaml') in your current record mode ('none').

The VCR docs says the default mode is "once" and pytest-recording doesn't mention the default mode, implying it follows VCR's.

To Reproduce
Use the sample test in the docs,

@pytest.mark.vcr
def test_single():
    actualResponse = requests.get("https://httpbin.org/get")
    assert actualResponse.status_code == 200

Expected behaviour
No errors.

Environment (please complete the following information):

  • OS: MacOS
  • Python version: 3.8.7
  • pytest-recording version: 0.11.0
  • pytest version: 6.2.2
@Stranger6667
Copy link
Collaborator

Thank you for pointing this out!

I completely missed mentioning it in the docs - this behavior is intentional to avoid network calls by default. It was a major problem at kiwi.com when I was working there, and therefore we choose a more conservative approach here. I'll update the docs soon.

@Stranger6667
Copy link
Collaborator

The docs are updated

@arthurio
Copy link

arthurio commented Jul 2, 2021

@Stranger6667 For my personal case I wanted to have once by default, so I set the config:

@pytest.fixture(scope="module")
def vcr_config():
    return {
        "record_mode": "once",
   }

Unfortunately, when you do that, passing options to pytest doesn't overwrite it... e.g. pytest --record-mode=rewrite would still execute with once. Should I open another issue for that or is there another trick I don't know about?

@Stranger6667
Copy link
Collaborator

@arthurio
Yes, please, open a separate issue for it

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