{"id":22530,"library":"vcrpy-unittest","title":"vcrpy-unittest","description":"Provides a decorator `@use_cassette` for integrating vcr.py into Python's unittest framework. Current version 0.1.7, updated infrequently.","status":"active","version":"0.1.7","language":"python","source_language":"en","source_url":"https://github.com/agriffis/vcrpy-unittest","tags":["vcrpy","testing","unittest","http-recording"],"install":[{"cmd":"pip install vcrpy-unittest","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core library for recording HTTP interactions","package":"vcrpy","optional":false}],"imports":[{"note":"Package name uses underscores not hyphens.","wrong":"from vcrpy_unittest import use_cassette","symbol":"use_cassette","correct":"from vcr_unittest import use_cassette"}],"quickstart":{"code":"import unittest\nfrom vcr_unittest import use_cassette\n\nclass TestMyAPI(unittest.TestCase):\n    @use_cassette('fixtures/cassettes/test_request.yaml')\n    def test_request(self):\n        import requests\n        resp = requests.get('http://httpbin.org/get')\n        self.assertEqual(resp.status_code, 200)","lang":"python","description":"Decorate a test method with @use_cassette to automatically record/replay HTTP interactions."},"warnings":[{"fix":"Use `@use_cassette(os.path.join(os.path.dirname(__file__), 'fixtures/cassettes/test.yaml'))`","message":"The cassette file path is relative to the working directory, not the test file. Use an absolute path or ensure correct working directory.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure decorated method belongs to a unittest.TestCase class.","message":"The decorator only works on instance methods of unittest.TestCase subclasses. It will break on standalone functions or other test runners (pytest).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from vcr_unittest import use_cassette`.","cause":"Using hyphenated package name instead of underscored one.","error":"ImportError: cannot import name 'use_cassette' from 'vcrpy_unittest'"},{"fix":"`pip install vcrpy-unittest` and then import `from vcr_unittest import use_cassette`.","cause":"Maybe older version or wrong import; check vcr_unittest is installed and import correctly.","error":"AttributeError: module 'vcr_unittest' has no attribute 'use_cassette'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}