Skip to content

Commit 0d538a0

Browse files
committed
json tests: adapt to newer ruamel.yaml
1 parent 28803b0 commit 0d538a0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/json_schema/test_cwl_schema.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# WARNING: do not use 'pyyaml' (import yaml), it does invalid parsing of some scientific number representations
1616
# see 'Numbers in scientific notation without dot are parsed as string' (https://github.com/yaml/pyyaml/issues/173)
1717
# builtin 'json' and 'simplejson' also have this issue (https://github.com/common-workflow-language/cwl-v1.2/issues/252)
18-
from ruamel import yaml
18+
from ruamel.yaml import YAML
1919
from ruamel.yaml.scanner import ScannerError
2020

2121
# https://raw.githubusercontent.com/common-workflow-language/cwl-v1.2/1.2.1_proposed/conformance_tests.yaml
@@ -76,15 +76,16 @@ def load_file(file_path: str, text: bool = False) -> Union[JSON, str]:
7676
:returns: loaded contents either parsed and converted to Python objects or as plain text.
7777
:raises ValueError: if YAML or JSON cannot be parsed or loaded from location.
7878
"""
79+
yaml = YAML(typ='safe', pure=True)
7980
try:
8081
if is_remote_file(file_path):
8182
headers = {"Accept": "text/plain"}
8283
resp = requests.get(file_path, headers=headers)
8384
if resp.status_code != 200:
8485
raise ValueError("Loading error: [%s]", file_path)
85-
return resp.content if text else yaml.safe_load(resp.content)
86+
return resp.content if text else yaml.load(resp.content)
8687
with open(file_path, mode="r", encoding="utf-8") as f:
87-
return f.read() if text else yaml.safe_load(f)
88+
return f.read() if text else yaml.load(f)
8889
except OSError as exc:
8990
LOGGER.debug("Loading error: %s", exc, exc_info=exc)
9091
raise

0 commit comments

Comments
 (0)