Skip to content

Commit

Permalink
Fix setting of source_url in context for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasl committed Nov 2, 2015
1 parent 9978eac commit 85f3049
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rdflib_jsonld/context.py
Expand Up @@ -192,7 +192,7 @@ def load(self, source, base=None):
self._read_source(source, source_url)

def _prep_sources(self, base, inputs, sources, referenced_contexts=None,
source_url=None):
in_source_url=None):
referenced_contexts = referenced_contexts or set()
for source in inputs:
if isinstance(source, basestring):
Expand All @@ -203,6 +203,8 @@ def _prep_sources(self, base, inputs, sources, referenced_contexts=None,
source = source_to_json(source_url)
if CONTEXT not in source:
raise errors.INVALID_REMOTE_CONTEXT
else:
source_url = in_source_url

if isinstance(source, dict):
if CONTEXT in source:
Expand Down
14 changes: 13 additions & 1 deletion test/test_context.py
Expand Up @@ -132,7 +132,19 @@ def test_loading_contexts():
def test_use_base_in_local_context():
ctx = Context({'@base': "/local"})
assert ctx.base == '/local'
# Ignore @base in remote contexts

def test_override_base():
ctx = Context(base="http://example.org/app/data/item",
source={'@base': "http://example.org/"})
assert ctx.base == "http://example.org/"

def test_set_null_base():
ctx = Context(base="http://example.org/app/data/item",
source={'@base': None})
assert ctx.base is None
assert ctx.resolve_iri("../other") == "../other"

def test_ignore_base_remote_context():
ctx_url = "http://example.org/remote-base.jsonld"
SOURCES[ctx_url] = {'@context': {'@base': "/remote"}}
ctx = Context(ctx_url)
Expand Down

0 comments on commit 85f3049

Please sign in to comment.