Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with non-raised ValidationError with jsonschema 1.19 #424

Closed
olebole opened this issue Feb 20, 2024 · 2 comments · Fixed by #425
Closed

Test failures with non-raised ValidationError with jsonschema 1.19 #424

olebole opened this issue Feb 20, 2024 · 2 comments · Fixed by #425

Comments

@olebole
Copy link
Contributor

olebole commented Feb 20, 2024

In Debian, the jsonschema package was now updated to 4.19.2, and this causes two asdf-standard tests to fail:

_____________________ test_nested_object_validation[path0] _____________________

path = PosixPath('/usr/lib/python3/dist-packages/asdf_standard/resources/schemas/stsci.edu/asdf/asdf-schema-1.0.0.yaml')
create_validator = <function create_validator.<locals>._create_validator at 0x7f060fec0720>

    @pytest.mark.parametrize("path", SCHEMAS_PATH.glob("asdf-schema-*.yaml"))
    def test_nested_object_validation(path, create_validator):
        """
        Test that the validations are applied to nested objects.
        """
        metaschema = load_yaml(path)
        validator = create_validator(metaschema)
    
        schema = {"$schema": metaschema["id"], "type": "object", "properties": {"foo": {"datatype": "float32"}}}
        # No error here
        validator.validate(schema)
    
        schema = {"$schema": metaschema["id"], "type": "object", "properties": {"foo": {"datatype": "banana"}}}
>       with pytest.raises(ValidationError, match="'banana' is not valid"):
E       Failed: DID NOT RAISE <class 'jsonschema.exceptions.ValidationError'>

../build.N1i/src/tests/test_asdf_schema.py:27: Failed

and

_____________________ test_nested_object_validation[path0] _____________________

path = PosixPath('/usr/lib/python3/dist-packages/asdf_standard/resources/schemas/stsci.edu/yaml-schema/draft-01.yaml')
create_validator = <function create_validator.<locals>._create_validator at 0x7f060fec0720>

    @pytest.mark.parametrize("path", YAML_SCHEMA_PATH.glob("*.yaml"))
    def test_nested_object_validation(path, create_validator):
        """
        Test that the validations are applied to nested objects.
        """
        metaschema = load_yaml(path)
        validator = create_validator(metaschema)
    
        schema = {"$schema": metaschema["id"], "type": "object", "properties": {"foo": {"flowStyle": "block"}}}
        # No error here
        validator.validate(schema)
    
        schema = {"$schema": metaschema["id"], "type": "object", "properties": {"foo": {"flowStyle": "funky"}}}
>       with pytest.raises(ValidationError, match="'funky' is not one of"):
E       Failed: DID NOT RAISE <class 'jsonschema.exceptions.ValidationError'>

../build.N1i/src/tests/test_yaml_schema.py:27: Failed

In both cases the with pytest.raises(…) lines just below the reported lines would also fail; it seems that the ValidationError is not raised anymore in all these cases.

Full test log here. This is also reported as Debian#1064275.

  • asdf-standard: 1.0.3
  • jsonschema: 1.19
  • Python: 3.11, 3.12
@braingram
Copy link
Contributor

Thanks for opening the issue.

This is known to to be the case as more recent versions of jsonschema dropped support for features required here (and have not re-added those features). There is an upper pin for jsonschema in the test requirements in pyproject.toml to account for this:

'jsonschema<4.18',

As the upper pin is only for test requirements (jsonschema is not required to install asdf-standard) can the older version be installed during testing of the debian package (to match what is done here for the packages released on pypi)?

@olebole
Copy link
Contributor Author

olebole commented Feb 20, 2024

Ah, OK. No, we don't have this possibility, but I will patch out the failing tests then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants