mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
On Python 3, response.msg.keys() contains the same value multiple times if there are multiple headers with the same value. Work around this by converting to a set before iterating over it.
23 lines
802 B
Python
23 lines
802 B
Python
import vcr
|
|
from six.moves.urllib.request import urlopen
|
|
|
|
|
|
def test_recorded_request_uri_with_redirected_request(tmpdir):
|
|
with vcr.use_cassette(str(tmpdir.join('test.yml'))) as cass:
|
|
assert len(cass) == 0
|
|
urlopen('http://httpbin.org/redirect/3')
|
|
assert cass.requests[0].uri == 'http://httpbin.org/redirect/3'
|
|
assert cass.requests[3].uri == 'http://httpbin.org/get'
|
|
assert len(cass) == 4
|
|
|
|
|
|
def test_records_multiple_header_values(tmpdir, httpserver):
|
|
httpserver.serve_content('Hello!', headers=[('foo', 'bar'), ('foo', 'baz')])
|
|
|
|
with vcr.use_cassette(str(tmpdir.join('test.yml'))) as cass:
|
|
assert len(cass) == 0
|
|
|
|
urlopen(httpserver.url)
|
|
assert len(cass) == 1
|
|
assert cass.responses[0]['headers']['foo'] == ['bar', 'baz']
|