Registry / testing / vcrpy-unittest

vcrpy-unittest

JSON →
library0.1.7pypypi✓ verified 85d ago

Provides a decorator `@use_cassette` for integrating vcr.py into Python's unittest framework. Current version 0.1.7, updated infrequently.

pip install vcrpy-unittest
INSTALL
IMPORT
SIG · VCRPY-UNITTEST
V
vcrpy-unittest
testingpythonv0.1.7
Install
2.5s avg
Import
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.5s · import 0.000s · 22MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

use_cassette
from vcr_unittest import VCRMixin
from vcr_unittest import use_cassette
VCRTestCase
from vcr_unittest import VCRTestCase
VCRMixin
from vcr_unittest import VCRMixin

Decorate a test method with @use_cassette to automatically record/replay HTTP interactions.

import unittest from vcr_unittest import use_cassette class TestMyAPI(unittest.TestCase): @use_cassette('fixtures/cassettes/test_request.yaml') def test_request(self): import requests resp = requests.get('http://httpbin.org/get') self.assertEqual(resp.status_code, 200)
Debug
Known issues
gotchaThe cassette file path is relative to the working directory, not the test file. Use an absolute path or ensure correct working directory.
fix
Use `@use_cassette(os.path.join(os.path.dirname(__file__), 'fixtures/cassettes/test.yaml'))`
affects: all
gotchaThe decorator only works on instance methods of unittest.TestCase subclasses. It will break on standalone functions or other test runners (pytest).
fix
Ensure decorated method belongs to a unittest.TestCase class.
affects: all
Upgrade
Version history
0.1.7latest on PyPI · released Sep 25, 2018
Audit
Dependencies
vcrpyrequiredCore library for recording HTTP interactions
Agent activity
6 hits · last 30 days
node
6
Resources
vcrpy-unittest — pip install vcrpy-unittest · libregistry