Repository: python-openapi/openapi-schema-validator (language: python)

Issue:
test_array_prefixitems_invalid[value0] failing on 0.6.2
Hi, we're seeing the following test fail. Our environment is

- Python 3.11.6
- jsonschema 4.20.0
- jsonschema-specifications  2023.11.2
- rfc3339-validator 0.1.4

```
openapi-schema-validator> ______ TestOAS31ValidatorValidate.test_array_prefixitems_invalid[value0] _______
openapi-schema-validator> 
openapi-schema-validator> self = <test_validators.TestOAS31ValidatorValidate object at 0x7ffff5d0f710>
openapi-schema-validator> validator_class = <class 'jsonschema.validators.create.<locals>.Validator'>
openapi-schema-validator> value = [1600, 'Pennsylvania', 'Avenue', 'NW', 'Washington']
openapi-schema-validator> 
openapi-schema-validator>     @pytest.mark.parametrize(
openapi-schema-validator>         "value",
openapi-schema-validator>         [
openapi-schema-validator>             [1600, "Pennsylvania", "Avenue", "NW", "Washington"],
openapi-schema-validator>         ],
openapi-schema-validator>     )
openapi-schema-validator>     def test_array_prefixitems_invalid(self, validator_class, value):
openapi-schema-validator>         schema = {
openapi-schema-validator>             "type": "array",
openapi-schema-validator>             "prefixItems": [
openapi-schema-validator>                 {"type": "number"},
openapi-schema-validator>                 {"type": "string"},
openapi-schema-validator>                 {"enum": ["Street", "Avenue", "Boulevard"]},
openapi-schema-validator>                 {"enum": ["NW", "NE", "SW", "SE"]},
openapi-schema-validator>             ],
openapi-schema-validator>             "items": False,
openapi-schema-validator>         }
openapi-schema-validator>         validator = validator_class(
openapi-schema-validator>             schema,
openapi-schema-validator>             format_checker=oas31_format_checker,
openapi-schema-validator>         )
openapi-schema-validator>     
openapi-schema-validator>         with pytest.raises(ValidationError) as excinfo:
openapi-schema-validator>             validator.validate(value)
openapi-schema-validator>     
openapi-schema-validator>         error = "Expected at most 4 items, but found 5"
openapi-schema-validator> >       assert error in str(excinfo.value)
openapi-schema-validator> E       assert 'Expected at most 4 items, but found 5' in "Expected at most 4 items but found 1 extra: 'Washington'\n\nFailed validating 'items' in schema:\n    {'items': False,\n     'prefixItems': [{'type': 'number'},\n                     {'type': 'string'},\n                     {'enum': ['Street', 'Avenue', 'Boulevard']},\n                     {'enum': ['NW', 'NE', 'SW', 'SE']}],\n     'type': 'array'}\n\nOn instance:\n    [1600, 'Pennsylvania', 'Avenue', 'NW', 'Washington']"
openapi-schema-validator> E        +  where "Expected at most 4 items but found 1 extra: 'Washington'\n\nFailed validating 'items' in schema:\n    {'items': False,\n     'prefixItems': [{'type': 'number'},\n                     {'type': 'string'},\n                     {'enum': ['Street', 'Avenue', 'Boulevard']},\n                     {'enum': ['NW', 'NE', 'SW', 'SE']}],\n     'type': 'array'}\n\nOn instance:\n    [1600, 'Pennsylvania', 'Avenue', 'NW', 'Washington']" = str(<ValidationError: "Expected at most 4 items but found 1 extra: 'Washington'">)
openapi-schema-validator> E        +    where <ValidationError: "Expected at most 4 items but found 1 extra: 'Washington'"> = <ExceptionInfo <ValidationError: "Expected at most 4 items but found 1 extra: 'Washington'"> tblen=2>.value
openapi-schema-validator> 
openapi-schema-validator> error      = 'Expected at most 4 items, but found 5'
openapi-schema-validator> excinfo    = <ExceptionInfo <ValidationError: "Expected at most 4 items but found 1 extra: 'Washington'"> tblen=2>
openapi-schema-validator> schema     = {'items': False,
openapi-schema-validator>  'prefixItems': [{'type': 'number'},
openapi-schema-validator>                  {'type': 'string'},
openapi-schema-validator>                  {'enum': ['Street', 'Avenue', 'Boulevard']},
openapi-schema-validator>                  {'enum': ['NW', 'NE', 'SW', 'SE']}],
openapi-schema-validator>  'type': 'array'}
openapi-schema-validator> self       = <test_validators.TestOAS31ValidatorValidate object at 0x7ffff5d0f710>
openapi-schema-validator> validator  = Validator(schema={'items': False, 'prefixItems': [{'type': 'number'}, {'type': 'string'}, {'enum': ['Street', 'Avenue', 'Boulevard']}, {'enum': ['NW', 'NE', 'SW', 'SE']}], 'type': 'array'}, format_checker=<FormatChecker checkers=['date', 'date-time', 'double', 'email', 'float', 'idn-email', 'int32', 'int64', 'ipv4', 'ipv6', 'password', 'regex', 'time', 'uuid']>)
openapi-schema-validator> validator_class = <class 'jsonschema.validators.create.<locals>.Validator'>
openapi-schema-validator> value      = [1600, 'Pennsylvania', 'Avenue', 'NW', 'Washington']
openapi-schema-validator> 
openapi-schema-validator> tests/integration/test_validators.py:867: AssertionError
```


Discussion / hints:

Fix patch:
diff --git a/poetry.lock b/poetry.lock
index 4914c0a..a8672e7 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -569,13 +569,13 @@ i18n = ["Babel (>=2.7)"]
 
 [[package]]
 name = "jsonschema"
-version = "4.19.1"
+version = "4.21.1"
 description = "An implementation of JSON Schema validation for Python"
 optional = false
 python-versions = ">=3.8"
 files = [
-    {file = "jsonschema-4.19.1-py3-none-any.whl", hash = "sha256:cd5f1f9ed9444e554b38ba003af06c0a8c2868131e56bfbef0550fb450c0330e"},
-    {file = "jsonschema-4.19.1.tar.gz", hash = "sha256:ec84cc37cfa703ef7cd4928db24f9cb31428a5d0fa77747b8b51a847458e0bbf"},
+    {file = "jsonschema-4.21.1-py3-none-any.whl", hash = "sha256:7996507afae316306f9e2290407761157c6f78002dcf7419acb99822143d1c6f"},
+    {file = "jsonschema-4.21.1.tar.gz", hash = "sha256:85727c00279f5fa6bedbe6238d2aa6403bedd8b4864ab11207d07df3cc1b2ee5"},
 ]
 
 [package.dependencies]


Test patch:
diff --git a/tests/integration/test_validators.py b/tests/integration/test_validators.py
index 07bc4df..07dfaa9 100644
--- a/tests/integration/test_validators.py
+++ b/tests/integration/test_validators.py
@@ -863,5 +863,10 @@ def test_array_prefixitems_invalid(self, validator_class, value):
         with pytest.raises(ValidationError) as excinfo:
             validator.validate(value)
 
-        error = "Expected at most 4 items, but found 5"
-        assert error in str(excinfo.value)
+        errors = [
+            # jsonschema < 4.20.0
+            "Expected at most 4 items, but found 5",
+            # jsonschema >= 4.20.0
+            "Expected at most 4 items but found 1 extra",
+        ]
+        assert any(error in str(excinfo.value) for error in errors)