[FEATURE] usage for doctests
See original GitHub issueForeword: thank you for this plugin, I like the API, and it is really useful.
Is your feature request related to a problem? Please describe.
The plugin works very well for normal tests, but I’d really like to use it with doctests.
I run those with pytest --doctest-modules
and/or pytest --doctest-glob="*.rst"
. I can define a conftest.py
file, but in it I can define fixtures, and not tests, so I cannot use the pytest.mark.vcr
Describe the solution you’d like
I’d like to be able to configure the tests to use a cassette/several cassettes for the tests in (say) the README and the modules, and then the pytest --doctest-modules
would record and use the cassette instead of calling the network.
Describe alternatives you’ve considered
I can add this in conftest.py
:
from vcr import use_cassette
@pytest.fixture(autouse=True)
def with_cassette():
with use_cassette("tests/doctests/cassette.yaml", record_mode="once"):
yield
But this does not respect whatever will be passed to the command line arguments as it hardcodes the cassette and record mode. If it creates a cassette for each file, that would be better, instead of using one big cassette.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
For what it’s worth, I hacked something like this, I put it here for others / if I do not have the bandwidth to make a proper PR:
In
conftest.py
OK, thanks for your quick reply! If I come up with something usable, I’ll make a PR, but not sure I can do it in the next few weeks.