Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- When compacting, expands the index mapping first, then compacts that expanded IRI, matching the JSON-LD API compaction correction for compact-IRI index mappings. Fixes testcases [compact#t0112](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#t0112) and [compact#t0113](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#t0113).
- Fixes `AttributeError` when compacting with `@none`: the `@type` map compaction path now only calls `.pop()` and inspects keys when `compacted_item` is actually an object. Fixes [compact#tm023](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#tm023)
- An empty property-scoped context no longer resets the active context in `_create_term_definition`. Now only explicit null becomes False; empty contexts are preserved. Fixes [compact#tc028](https://w3c.github.io/json-ld-api/tests/compact-manifest.html#tc028) and [toRdf#tc036](https://w3c.github.io/json-ld-api/tests/toRdf-manifest.html#tc036).
- Options from the test manifest now override the options configured in `create_test_options()`, instead of the other way around. This fixes tests not able to override default options in the test-setup such as `extractAllScripts`. Fixes [html#tf004](https://w3c.github.io/json-ld-api/tests/html-manifest#tf004).
- When `@type` is `@json` in a frame, it no longer raises an "Invalid JSON-LD syntax" error. Fixes [frame#t0069](https://w3c.github.io/json-ld-framing/tests/frame-manifest.html#t0069).

### Added
- `pyld.DocumentLoader` abstract base class for class-based document loaders,
Expand Down
8 changes: 5 additions & 3 deletions lib/pyld/jsonld.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ def get_values(subject, property):

:return: all of the values for a subject's property as an array.
"""
return JsonLdProcessor.arrayify(subject.get(property) or [])
return JsonLdProcessor.arrayify(subject.get(property)) if property in subject else []

@staticmethod
def remove_property(subject, property):
Expand Down Expand Up @@ -4487,8 +4487,10 @@ def _validate_frame(self, frame):
)
if '@type' in frame[0]:
for type_ in JsonLdProcessor.arrayify(frame[0]['@type']):
# @id must be wildcard or IRI
if not (_is_object(type_) or _is_absolute_iri(type_)) or (
# @type must be wildcard, @json, or IRI
if not (
_is_object(type_) or type_ == '@json' or _is_absolute_iri(type_)
) or (
_is_string(type_) and type_.startswith('_:')
):
raise JsonLdError(
Expand Down
15 changes: 5 additions & 10 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,12 @@ def create(test):
http_options = ['contentType', 'httpLink', 'httpStatus', 'redirectTo']
test_options = test.data.get('option', {})
options = {}
options.update(opts or {})
# Non-http options from manifest get priority over configured options
for k, v in test_options.items():
if k not in http_options:
options[k] = v
options['documentLoader'] = create_document_loader(test)
options.update(opts or {})
if 'expandContext' in options:
filename = os.path.join(test.dirname, options['expandContext'])
options['expandContext'] = read_json(filename)
Expand Down Expand Up @@ -954,16 +955,13 @@ def write(self, filename):
# skip tests where behavior changed for a 1.1 processor
# see JSON-LD 1.0 Errata
'specVersion': ['json-ld-1.0'],
'idRegex': [
# uncategorized html
'.*html-manifest#tf004$',
],
'idRegex': [],
},
'fn': 'flatten',
'params': [
read_test_url('input'),
read_test_property('context'),
create_test_options(),
create_test_options({"extractAllScripts": False}),
],
},
'jld:FrameTest': {
Expand All @@ -972,10 +970,7 @@ def write(self, filename):
# skip tests where behavior changed for a 1.1 processor
# see JSON-LD 1.0 Errata
'specVersion': ['json-ld-1.0'],
'idRegex': [
# uncategorized
'.*frame-manifest#t0069$',
],
'idRegex': [],
},
'fn': 'frame',
'params': [
Expand Down
Loading