mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Don't assume params to be a dictionary
aiohttp also fails with pass parameter values with types other than string, integer or float.
This commit is contained in:
committed by
Jair Henrique
parent
b1bc5c3a02
commit
7add8c0bab
@@ -154,7 +154,7 @@ def test_post(tmpdir, scheme, body, caplog):
|
|||||||
def test_params(tmpdir, scheme):
|
def test_params(tmpdir, scheme):
|
||||||
url = scheme + "://httpbin.org/get"
|
url = scheme + "://httpbin.org/get"
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
params = {"a": 1, "b": False, "c": "c"}
|
params = {"a": 1, "b": 2, "c": "c"}
|
||||||
|
|
||||||
with vcr.use_cassette(str(tmpdir.join("get.yaml"))) as cassette:
|
with vcr.use_cassette(str(tmpdir.join("get.yaml"))) as cassette:
|
||||||
_, response_json = get(url, output="json", params=params, headers=headers)
|
_, response_json = get(url, output="json", params=params, headers=headers)
|
||||||
@@ -168,7 +168,7 @@ def test_params(tmpdir, scheme):
|
|||||||
def test_params_same_url_distinct_params(tmpdir, scheme):
|
def test_params_same_url_distinct_params(tmpdir, scheme):
|
||||||
url = scheme + "://httpbin.org/get"
|
url = scheme + "://httpbin.org/get"
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
params = {"a": 1, "b": False, "c": "c"}
|
params = {"a": 1, "b": 2, "c": "c"}
|
||||||
|
|
||||||
with vcr.use_cassette(str(tmpdir.join("get.yaml"))) as cassette:
|
with vcr.use_cassette(str(tmpdir.join("get.yaml"))) as cassette:
|
||||||
_, response_json = get(url, output="json", params=params, headers=headers)
|
_, response_json = get(url, output="json", params=params, headers=headers)
|
||||||
|
|||||||
@@ -244,8 +244,6 @@ def vcr_request(cassette, real_request):
|
|||||||
|
|
||||||
request_url = URL(url)
|
request_url = URL(url)
|
||||||
if params:
|
if params:
|
||||||
for k, v in params.items():
|
|
||||||
params[k] = str(v)
|
|
||||||
request_url = URL(url).with_query(params)
|
request_url = URL(url).with_query(params)
|
||||||
|
|
||||||
c_header = headers.pop(hdrs.COOKIE, None)
|
c_header = headers.pop(hdrs.COOKIE, None)
|
||||||
|
|||||||
Reference in New Issue
Block a user