Skip to content

Commit

Permalink
change directory back to cwd after running jsonld tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysommer committed Jul 9, 2021
1 parent e8d8a08 commit e9f3f9c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
25 changes: 15 additions & 10 deletions test/jsonld/test_localsuite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import environ, chdir, path as p
import os
from os import environ, chdir, getcwd, path as p
import json
from . import runner

Expand All @@ -24,13 +25,17 @@ def read_manifest():


def test_suite():
old_cwd = getcwd()
chdir(testsuite_dir)
for cat, num, inputpath, expectedpath, context, options in read_manifest():
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options
try:
for cat, num, inputpath, expectedpath, context, options in read_manifest():
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options
finally:
chdir(old_cwd)
32 changes: 18 additions & 14 deletions test/jsonld/test_onedotone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os import environ, chdir, path as p
from os import environ, chdir, getcwd, path as p
import json
from . import runner

Expand Down Expand Up @@ -155,18 +155,22 @@ def test_suite():
skiptests = unsupported_tests
if SKIP_KNOWN_BUGS:
skiptests += known_bugs
old_cwd = getcwd()
chdir(test_dir)
for cat, num, inputpath, expectedpath, context, options in read_manifest(skiptests):
if options:
if SKIP_1_0_TESTS and "specVersion" in options and str(options["specVersion"]).lower() == "json-ld-1.0":
# Skip the JSON v1.0 tests
continue
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options
try:
for cat, num, inputpath, expectedpath, context, options in read_manifest(skiptests):
if options:
if SKIP_1_0_TESTS and "specVersion" in options and str(options["specVersion"]).lower() == "json-ld-1.0":
# Skip the JSON v1.0 tests
continue
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options
finally:
chdir(old_cwd)

30 changes: 16 additions & 14 deletions test/jsonld/test_testsuite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os import environ, chdir, path as p
from os import environ, chdir, getcwd, path as p
import json
import rdflib
import rdflib.plugins.parsers.jsonld as parser
Expand Down Expand Up @@ -79,24 +79,26 @@ def read_manifest(skiptests):
def test_suite(skip_known_bugs=True):
default_allow = rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS
rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS = allow_lists_of_lists

skiptests = unsupported_tests
if skip_known_bugs:
skiptests += known_bugs
old_cwd = getcwd()
chdir(test_dir)
runner.DEFAULT_PARSER_VERSION = 1.0
for cat, num, inputpath, expectedpath, context, options in read_manifest(skiptests):
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
# func.description = "%s-%s-%s" % (group, case)
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options

rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS = default_allow
try:
for cat, num, inputpath, expectedpath, context, options in read_manifest(skiptests):
if inputpath.endswith(".jsonld"): # toRdf
if expectedpath.endswith(".jsonld"): # compact/expand/flatten
func = runner.do_test_json
else: # toRdf
func = runner.do_test_parser
else: # fromRdf
func = runner.do_test_serializer
# func.description = "%s-%s-%s" % (group, case)
yield func, TC_BASE, cat, num, inputpath, expectedpath, context, options
finally:
rdflib.plugins.parsers.jsonld.ALLOW_LISTS_OF_LISTS = default_allow
chdir(old_cwd)


if __name__ == "__main__":
Expand Down

0 comments on commit e9f3f9c

Please sign in to comment.