Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion responses/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def json_params_matcher(
def match(request: PreparedRequest) -> Tuple[bool, str]:
reason = ""
request_body = request.body
json_params = (params or {}) if not isinstance(params, list) else params
json_params = {} if params is None else params
try:
if isinstance(request.body, bytes):
try:
Expand Down
17 changes: 17 additions & 0 deletions responses/tests/test_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,23 @@ def test_json_params_matcher_body_is_gzipped():
assert result == (True, "")


@pytest.mark.parametrize(
("param", "body_str"),
[
(0, "0"),
(False, "false"),
("", '""'),
(0.0, "0.0"),
(True, "true"),
("hello", '"hello"'),
],
)
def test_json_params_matcher_primitives(param, body_str):
mock_request = Mock(body=body_str)
result = matchers.json_params_matcher(param)(mock_request)
assert result == (True, "")


def test_urlencoded_params_matcher_blank():
@responses.activate
def run():
Expand Down