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

Allow using pytest-recording with a command-line flag only #109

Open
Peque opened this issue Jun 6, 2023 · 1 comment
Open

Allow using pytest-recording with a command-line flag only #109

Peque opened this issue Jun 6, 2023 · 1 comment

Comments

@Peque
Copy link

Peque commented Jun 6, 2023

It seems like right now you need to define which functions will make use of vcr with a decorator. It would be great if there was a way to automatically enable vcr for all tests without requiring any change in the source code.

For example, having a flag like pytest --vcr would automatically enable VCR for all requests.

This way, tests would run in any environment without vcr nor pytest-recording installed (i.e.: CI/CD/deployment) and, for those wanting to accelerate local testing, it would be as simple as installing the packages and adding the --vcr flag.

Not sure this is even possible. 🤷 😄

@Stranger6667
Copy link
Collaborator

Stranger6667 commented Jun 6, 2023

Hi!

Yep, it could be a new CLI option that would work inside this condition elif vcr_markers or enable_recording:

This feature should be relatively straightforward to implement, I don't have the capacity to work on it myself but I will assist with reviews. I see the following steps:

  • Extend pytest_addoption with a boolean option (similar to --disable-recording there)
  • Create a fixture enable_recording (similar to this)
  • Use the new enable_recording fixture inside vcr - elif vcr_markers or enable_recording:
  • Check that --disable-recording and --enable-recording are not used together (e.g. inside these fixture definitions)
  • Changelog entry
  • A test to verify this CLI option works + a test for conflicting options (as per notes above)
  • Document this flag in README

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

2 participants