summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Sommer <Ashley.Sommer@csiro.au>2021-07-09 10:27:31 +1000
committerAshley Sommer <Ashley.Sommer@csiro.au>2021-07-09 10:27:31 +1000
commite9f3f9c6bba987333f3bb2ccc4e78d49d8aa961a (patch)
tree481ece2be8cdf582f833df0c7289da2295abb0d6
parente8d8a083e77e7a7bb17b52c8847e0dbdd3f558ba (diff)
downloadrdflib-e9f3f9c6bba987333f3bb2ccc4e78d49d8aa961a.tar.gz
change directory back to cwd after running jsonld tests
-rw-r--r--test/jsonld/test_localsuite.py25
-rw-r--r--test/jsonld/test_onedotone.py32
-rw-r--r--test/jsonld/test_testsuite.py30
3 files changed, 49 insertions, 38 deletions
diff --git a/test/jsonld/test_localsuite.py b/test/jsonld/test_localsuite.py
index 1f9acd82..30701653 100644
--- a/test/jsonld/test_localsuite.py
+++ b/test/jsonld/test_localsuite.py
@@ -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
@@ -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)
diff --git a/test/jsonld/test_onedotone.py b/test/jsonld/test_onedotone.py
index bdd868d3..87b6a949 100644
--- a/test/jsonld/test_onedotone.py
+++ b/test/jsonld/test_onedotone.py
@@ -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
@@ -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)
diff --git a/test/jsonld/test_testsuite.py b/test/jsonld/test_testsuite.py
index 8f0300fd..68ab6c70 100644
--- a/test/jsonld/test_testsuite.py
+++ b/test/jsonld/test_testsuite.py
@@ -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
@@ -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__":