Skip to content

Commit 506640e

Browse files
committed
Handle http and https test suite URLs.
1 parent 70148ff commit 506640e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/runtests.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,21 @@ def create(test):
322322

323323

324324
def create_document_loader(test):
325-
base = 'http://json-ld.org/test-suite'
325+
httpBase = 'http://json-ld.org/test-suite'
326+
httpsBase = 'https://json-ld.org/test-suite'
326327
loader = jsonld.get_document_loader()
327328

329+
def is_test_suite_url(url):
330+
return url.startswith(httpBase) or url.startswith(httpsBase)
331+
332+
def strip_base(url):
333+
if url.startswith(httpBase):
334+
return url[len(httpBase):]
335+
elif url.startswith(httpsBase):
336+
return url[len(httpsBase):]
337+
else:
338+
raise Exception('unkonwn base')
339+
328340
def load_locally(url):
329341
doc = {'contextUrl': None, 'documentUrl': url, 'document': None}
330342
options = test.data.get('option')
@@ -352,7 +364,7 @@ def load_locally(url):
352364
else:
353365
#filename = os.path.join(
354366
# ROOT_MANIFEST_DIR, doc['documentUrl'][len(base):])
355-
filename = ROOT_MANIFEST_DIR + doc['documentUrl'][len(base):]
367+
filename = ROOT_MANIFEST_DIR + strip_base(doc['documentUrl'])
356368
try:
357369
doc['document'] = read_json(filename)
358370
except:
@@ -361,7 +373,7 @@ def load_locally(url):
361373

362374
def local_loader(url):
363375
# always load remote-doc and non-base tests remotely
364-
if ((not url.startswith(base) and url.find(':') != -1) or
376+
if ((not is_test_suite_url(url) and url.find(':') != -1) or
365377
test.manifest.data.get('name') == 'Remote document'):
366378
return loader(url)
367379

0 commit comments

Comments
 (0)