mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
Added test to confirm whether cStringIO works
This commit is contained in:
committed by
Kevin McCarthy
parent
b688dd362d
commit
c5eca93edc
@@ -43,3 +43,37 @@ def test_basic_json_use(tmpdir):
|
|||||||
with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.json', serializer='json'):
|
with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.json', serializer='json'):
|
||||||
response = urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
response = urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
assert 'Example domains' in response
|
assert 'Example domains' in response
|
||||||
|
|
||||||
|
def test_patched_content(tmpdir):
|
||||||
|
'''Ensure that what you pull from a cassette is what came from the request'''
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass:
|
||||||
|
response = urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 0
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass:
|
||||||
|
response2= urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.yaml'))) as cass:
|
||||||
|
response3= urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
assert response == response2
|
||||||
|
assert response2 == response3
|
||||||
|
|
||||||
|
def test_patched_content_json(tmpdir):
|
||||||
|
'''Ensure that what you pull from a json cassette is what came from the request'''
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass:
|
||||||
|
response = urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 0
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass:
|
||||||
|
response2= urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('synopsis.json')), serializer='json') as cass:
|
||||||
|
response3= urllib2.urlopen('http://www.iana.org/domains/reserved').read()
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
assert response == response2
|
||||||
|
assert response2 == response3
|
||||||
|
|||||||
Reference in New Issue
Block a user