Created
October 13, 2013 20:12
-
-
Save hpk42/6966904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
etamax_cassette = pytest.mark.betamax_cassette | |
class TestGitHubAPI: | |
def test_user(self, session, vcr): | |
vcr.use_cassette('user') | |
resp = session.get('https://api.github.com/user', | |
auth=('user', 'pass')) | |
assert resp.json()['login'] is not None | |
@betamax_cassette("repo") | |
def test_repo(self, session): | |
resp = session.get( | |
'https://api.github.com/repos/sigmavirus24/github3.py' | |
) | |
assert resp.json()['owner'] != {} | |
# or if we want to use recording for each method with automatically | |
# named cassettes | |
@pytest.mark.usefixtures("betamax_per_method") # use method-named cassettes | |
class TestGitHubAPIAuto: | |
def test_login(self, session): # use cassete TestGitHubAPIAuto.login | |
resp = session.get('https://api.github.com/user', | |
auth=('user', 'pass')) | |
assert resp.json()['login'] is not None | |
def test_repo(self, session): # use cassette TestGitHubAPIAuto.repo | |
resp = session.get( | |
'https://api.github.com/repos/sigmavirus24/github3.py' | |
) | |
assert resp.json()['owner'] != {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So in the case of github3.py (my main use-case of betamax), I store a requests session on the object, i.e.,
What I started doing was:
How could fixtures help in this case?