question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to specify `use_cassette`

See original GitHub issue

When there are many tests using the same request/response, what’s the best way to ensure they all use the same cassette? The vcr.use_cassette API clearly provides an option to name a cassette file. Is this exposed in pytest-vcr? e.g.

@pytest.mark.vcr(vcr_cassette_name='custom')

# or?

@pytest.mark.vcr(use_cassette='cassettes/custom.yaml')

Is this already noted in the read-the-docs? Where is it explained?

It seems like adding a decorator for VCR to a pytest-fixture does not work, or does it? If so, how?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ktosiekcommented, May 12, 2019

Currently passing the cassette name into the marker is not supported.

If the tests are grouped somehow (say, by class) you could override vcr_cassette_name for that scope:

@pytest.mark.vcr
class CommonCassetteTests:
    @pytest.fixture
    def vcr_cassette_name(self):
        return 'custom'

    def test_one(self):
        ...

    def test_two(self):
        ...

Otherwise you can use the vcr fixture to get a current VCR object:

# Note: don't mix the marker with explicit usage of "vcr"
def test_common1(vcr):
    with vcr.use_cassette('common'):
        ...

def test_common2(vcr):
    with vcr.use_cassette('common'):
        ...

I’m not sure what you mean by adding a decorator for VCR - could you rephrase, or provide an example of what you’ve tried?

0reactions
dazza-codescommented, Jul 13, 2019

Might be fixed by #25

Read more comments on GitHub >

github_iconTop Results From Across the Web

A modern guide to cassette tape players - Popular Science
To rewind something you're listening to, make sure you hold the cassette with the side you'll be listening to facing you. Then, you'll...
Read more >
How to Use a Cassette Player | Techwalla
Step 2. Find the "Eject" button and press it. Before you put a cassette in the machine, use a pencil or your small...
Read more >
How to Transfer Cassette Tape to Computer - wikiHow
1. Understand how cassette recording works. To record your cassette audio on your computer, you will need to connect your cassette player to...
Read more >
How to Record Cassette Tapes : 7 Steps - Instructables
1. When recoding music, it's best to record on blank tapes. You can find tapes at places like hardware stores or thrift stores,...
Read more >
Cassette Tapes - City of San Diego
If there is a tape inside, take it out and give it to a staff member. ... Once you are finished, right-click your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found