Skip to main content

betamax

Betamax is a VCR imitation for requests. This will make mocking out requests much easier. Tested on Travis CI.

Example Use

from betamax import Betamax
from requests import Session
from unittest import TestCase

with Betamax.configure() as config:
    config.cassette_library_dir = 'tests/fixtures/cassettes'


class TestGitHubAPI(TestCase):
    def setUp(self):
        self.session = Session()
        self.headers.update(...)

    # Set the cassette in a line other than the context declaration
    def test_user(self):
        with Betamax(self.session) as vcr:
            vcr.use_cassette('user')
            resp = self.session.get('https://api.github.com/user',
                                    auth=('user', 'pass'))
            assert resp.json()['login'] is not None

    # Set the cassette in line with the context declaration
    def test_repo(self):
        with Betamax(self.session).use_cassette('repo') as vcr:
            resp = self.session.get(
                'https://api.github.com/repos/sigmavirus24/github3.py'
                )
            assert resp.json()['owner'] != {}

VCR Cassette Compatiblity

Betamax can use any VCR-recorded cassette as of this point in time. The only caveat is that python-requests returns a URL on each response. VCR does not store that in a cassette now but we will. Any VCR-recorded cassette used to playback a response will unfortunately not have a URL attribute on responses that are returned. This is a minor annoyance but not something that can be fixed.

History

0.1.2 - 2013-09-21

  • Fix issues with how requests parses cookies out of responses

  • Fix unicode issues with Response#text (trying to use Response#json raises exception because it cannot use string decoding on a unicode string)

0.1.1 - 2013-09-19

  • Fix issue where there is a unicode character not in range(128)

0.1.0 - 2013-09-17

  • Initial Release

  • Support for VCR generated cassettes (JSON only)

  • Support for re_record_interval

  • Support for the once, all, new_episodes, all cassette modes

  • Support for filtering sensitive data

  • Support for the following methods of request matching:

    • Method

    • URI

    • Host

    • Path

    • Query String

    • Body

    • Headers

Metadata

Release files for betamax 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for betamax 0.1.2
File Size Uploaded Provenance
betamax-0.1.2.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for betamax 0.1.2
File Interpreter ABI Platform
betamax-0.1.2-py27-none-any.whl Python 2.7 none any Details

Total release size: 25.8 kB

Release files / betamax-0.1.2.tar.gz

Download URL betamax-0.1.2.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f4d35ff163d59c0c76f610308222372a2200db9b89ccb97110f793bef910ccf6
BLAKE2b-256 checksum
How to use checksums
a098fe69c266015c4ce48130e4287417e3806cb1a4d90f321d59e7886bb5075c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / betamax-0.1.2-py27-none-any.whl

Download URL betamax-0.1.2-py27-none-any.whl
Size 15.0 kB
Tags Python 2.7
SHA-256 checksum
How to use checksums
71766c809576f3626277c6c9f3e6c7340c1940ce07ea44c82370ac11a820c707
BLAKE2b-256 checksum
How to use checksums
bcada599064772593eb8e6c7455363a6c9ce439476fa3066b7ac942430b3a22c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for betamax 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page