Skip to content

Pytest for SHACL validation #159

@damian-oswald

Description

@damian-oswald

very nice work 🚀 thanks a lot!

In case you haven't done this in the other pytest scripts, you could add pyshacl to your tests. something like this:

def test_shacl_compliance():
    """Test: Runs PySHACL to ensure the ontology complies with its own defined NodeShapes."""
    from pyshacl import validate
    
    conforms, _, results_text = validate(
        str(TTL_FILE_PATH),
        shacl_graph=str(TTL_FILE_PATH),  # The shapes are inside the same TTL file
        data_graph_format="turtle",
        shacl_graph_format="turtle",
        inference='none',
        debug=False
    )
    assert conforms, f"SHACL validation failed:\n{results_text}"

Originally posted by @Cryphonectria in #154 (comment)

Metadata

Metadata

Assignees

Labels

SHACLAnything involving SHACL, the shape constraints languagepythonAny problem with a Python script or relatedtestingAny issue or idea regarding (automated) tests
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions