Skip to content

Commit

Permalink
Ensure proper sorting of list in error message
Browse files Browse the repository at this point in the history
Fixes problem where error message was con consistent between runs.
  • Loading branch information
ssbarnea committed May 5, 2022
1 parent 7949bf6 commit eef7417
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jsonschema/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def extras_msg(extras):
verb = "was"
else:
verb = "were"
return ", ".join(repr(extra) for extra in extras), verb
return ", ".join(repr(extra) for extra in sorted(extras)), verb


def ensure_list(thing):
Expand Down
4 changes: 2 additions & 2 deletions jsonschema/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def test_unevaluated_items(self):
message = self.message_for(instance=["foo", "bar"], schema=schema)
self.assertIn(
message,
"Unevaluated items are not allowed ('foo', 'bar' were unexpected)",
"Unevaluated items are not allowed ('bar', 'foo' were unexpected)",
)

def test_unevaluated_properties(self):
Expand All @@ -609,7 +609,7 @@ def test_unevaluated_properties(self):
self.assertEqual(
message,
"Unevaluated properties are not allowed "
"('foo', 'bar' were unexpected)",
"('bar', 'foo' were unexpected)",
)


Expand Down

0 comments on commit eef7417

Please sign in to comment.