-
-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Description
Describe the bug
The matcher query_param_matcher
cannot match query parameters that have an empty string value.
Additional context
This is because RequestsMock._parse_request_params
calls parse_qsl
with the default argument keep_blank_values=False
:
responses/responses/__init__.py
Line 1054 in cdd104d
for key, val in groupby(parse_qsl(urlsplit(url).query), lambda kv: kv[0]): |
This should be configurable, similar to allow_blank
in urlencoded_params_matcher
(see #533).
Version of responses
0.25.8
Steps to Reproduce
import responses
import requests
from responses import matchers
@responses.activate
def test_empty_query_param():
responses.get("http://example.com/foo", match=[matchers.query_param_matcher({"bar": ""})], json={})
response = requests.get("http://example.com/foo?bar=")
assert response.status_code == 200
Expected Result
The test passes.
Actual Result
The test fails:
E requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn't match any registered mock.
E
E Request:
E - GET http://example.com/foo?bar=
E
E Available matches:
E - GET http://example.com/foo Parameters do not match. {} doesn't match {'bar': ''}
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Product Owner