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.

Dynamically generate cassette's name

See original GitHub issue

At the moment you have to explicitly name the cassette file in the path parameter when using a decorator:

@vcr.use_cassette('article_header.yaml')
def test_get_article_header_text_from_url():
    # rest of function...
# cassette is saved as 'article_header.yaml'

Is it possible to dynamically generate cassette’s name so it’s taken from the decorated function instead?

@vcr.use_cassette(func_name)
def test_get_article_header_text_from_url():
    # rest of function...
# cassette is saved as 'test_get_article_header_text_from_url.yaml'

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanMalisoncommented, May 10, 2015

@klvbdmh You should be able to do what you want now with this tiny bit of additional configuration:

my_vcr = VCR(path_tranformer=VCR.ensure_suffix('.yaml'))
0reactions
IvanMalisoncommented, May 10, 2015

@kevin1024 I should have held off on putting this in master until you got a chance to take a look at it. I’m pretty happy with how things turned out, but the code is definitely more complicated, and though this is completely backwards compatible, there are some pretty significant changes underneath the hood.

Let me know what you think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Naming - Cassettes - Vcr - Relish
When inserting or using a cassette, the first argument is the cassette name. You can use any string for the name. If you...
Read more >
how do I dynamically generate multiple HTTP mock responses ...
Show activity on this post. I'm hitting an API and for each request, there was a recorded request/response in the cassette YAML file....
Read more >
fastly/blockbuster: VCR cassette manager - GitHub
Blockbuster. Build Status. Managing your VCR cassettes since 2016. The task of this gem is to take all your VCR cassettes and package...
Read more >
Cassette tape - Wikipedia
One artifact found on some commercially produced music cassettes was a sequence of test tones, called SDR (Super Dynamic Range, also called XDR,...
Read more >
best practices, test::unit, cassette per test? erasing cassettes?
a a cassette name based on the name you pass in. Does this seem like ... it on what Rails does with Test::Unit,...
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