diff --git a/README.rst b/README.rst index 8170aedc..ccc743f0 100644 --- a/README.rst +++ b/README.rst @@ -308,6 +308,7 @@ JSON encoded data """"""""""""""""" Matching JSON encoded data can be done with ``matchers.json_params_matcher()``. +It supports JSON dictionaries, lists, and scalar values. .. code-block:: python @@ -333,6 +334,25 @@ Matching JSON encoded data can be done with ``matchers.json_params_matcher()``. ) +To perform partial matching where the request dictionary may contain additional keys, pass ``strict_match=False``: + +.. code-block:: python + + @responses.activate + def test_partial_json(): + responses.post( + url="http://example.com/", + body="one", + match=[ + matchers.json_params_matcher({"page": "first"}, strict_match=False) + ], + ) + resp = requests.post( + "http://example.com/", + json={"page": "first", "extra_key": "extra_val"}, + ) + + Query Parameters Matcher ^^^^^^^^^^^^^^^^^^^^^^^^