Skip to content

Commit

Permalink
Merge pull request #103 from iolanta-tech/compact-manifest-tpr03
Browse files Browse the repository at this point in the history
compact manifest tpr03
  • Loading branch information
anatoly-scherbakov committed Jun 16, 2024
2 parents e566313 + 4f10a6b commit a124a2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ldtest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from urlpath import URL

from yaml_ld.compact import CompactOptions
from yaml_ld.expand import ExpandOptions
from yaml_ld.models import Document
from yaml_ld.to_rdf import ToRDFOptions
Expand Down Expand Up @@ -47,12 +48,15 @@ def _stream_kwargs(self):

if self.test.startswith('toRdf'):
options_class = ToRDFOptions
elif self.test.startswith('compact'):
options_class = CompactOptions
else:
options_class = ExpandOptions

yield 'options', options_class(
base=self.base,
extract_all_scripts=self.extract_all_scripts,
expand_context=self.ctx,
).model_dump(
by_alias=True,
exclude_defaults=True,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ def test_compact(
parse=yaml_ld.parse,
expand=yaml_ld.compact,
)
except AssertionError:
except (AssertionError, FailureToFail):
try:
test_against_ld_library(
test_case=test_case,
parse=_load_json_ld,
expand=jsonld.compact,
)
except AssertionError:
except (AssertionError, FailureToFail):
pytest.skip('This test fails for pyld as well as for yaml-ld.')
else:
raise
Expand Down
3 changes: 0 additions & 3 deletions yaml_ld/compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def compact( # noqa: WPS211
options: CompactOptions = CompactOptions(),
) -> Document | list[Document]:
"""Compact a JSON-LD document."""
if isinstance(document, (str, bytes)):
document = parse(document)

with except_json_ld_errors():
return jsonld.compact(
input_=document,
Expand Down

0 comments on commit a124a2a

Please sign in to comment.