Skip to content

Error Message for failed matches sorts arrays even if not originally sorted #704

@IanMoran

Description

@IanMoran

Describe the bug

When reporting a failure to match an incoming request with registered responses, arrays in a JSON body appear to be sorted even if they aren't sorted in reality, potentially masking the mismatch that caused the error.

Additional context

No response

Version of responses

0.24.1

Steps to Reproduce

import responses
import requests

json_match = {'array' : ['C', 'B', 'A']}

responses.post(url='http://example.com', 
body='{"example":"response"}',
match=[matchers.json_params_matcher(json_match)])

json_actual = {'array' : ['B', 'A', 'C']}
requests.post('http://example.com', json=json_actual)

Expected Result

Responses should throw an error with a message displaying the actual body compared to the registered mock, making the difference between the ordering of the two arrays clear.

Actual Result

Responses' error message appears, but displays both arrays as ['A', 'B', 'C'], making it seem like it should have been a match despite not being accurate to either array's actual state.

NOTE: This auto-sorting also occurs if the arrays DO match, but some other aspect of the json fails the comparison.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy