From 41b49c68e5377f44e54fb1596b233a8da21c24f1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 24 Apr 2024 17:00:19 +0300 Subject: [PATCH] Minor improvement to test failure message when a best match test fails. --- jsonschema/tests/test_exceptions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonschema/tests/test_exceptions.py b/jsonschema/tests/test_exceptions.py index 18be0589..4052b5f1 100644 --- a/jsonschema/tests/test_exceptions.py +++ b/jsonschema/tests/test_exceptions.py @@ -8,8 +8,12 @@ class TestBestMatch(TestCase): def best_match_of(self, instance, schema): errors = list(_LATEST_VERSION(schema).iter_errors(instance)) + msg = f"No errors found for {instance} under {schema!r}!" + self.assertTrue(errors, msg=msg) + best = exceptions.best_match(iter(errors)) reversed_best = exceptions.best_match(reversed(errors)) + self.assertEqual( best._contents(), reversed_best._contents(),