diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-08-04 22:51:25 +0900 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-10 08:33:55 +0000 |
commit | 7f2bc71e74c9914d65775a68a61781e9851f6238 (patch) | |
tree | 5346388794047adbb64e63633a4cbe003ab4f907 | |
parent | 89b3fa48d48ab559b582a0daa9daa6aac0d2604c (diff) | |
download | buildstream-7f2bc71e74c9914d65775a68a61781e9851f6238.tar.gz |
_yaml.pyx: Make shortname a mandatory argument to _yaml.load()
This ensures that important calls to this function do give some
thought to providing a reasonable shortname, which will be used
as a display name in errors.
This continues to support `None` as a shortname, which is used
in various tests which don't need to provide a reasonable user
facing error.
The buildstream.testing module now exports a `load_yaml` function
which only takes a filename and no shortname.
-rw-r--r-- | src/buildstream/_context.py | 7 | ||||
-rw-r--r-- | src/buildstream/_frontend/cli.py | 2 | ||||
-rw-r--r-- | src/buildstream/_project.py | 4 | ||||
-rw-r--r-- | src/buildstream/_workspaces.py | 2 | ||||
-rw-r--r-- | src/buildstream/_yaml.pyx | 2 | ||||
-rw-r--r-- | src/buildstream/testing/__init__.py | 3 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/mirror.py | 4 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/track.py | 2 | ||||
-rw-r--r-- | src/buildstream/testing/_yaml.py | 9 | ||||
-rw-r--r-- | src/buildstream/testing/runcli.py | 2 | ||||
-rw-r--r-- | tests/artifactcache/junctions.py | 2 | ||||
-rw-r--r-- | tests/elements/filter.py | 14 | ||||
-rw-r--r-- | tests/format/include_composition.py | 16 | ||||
-rw-r--r-- | tests/frontend/init.py | 10 | ||||
-rw-r--r-- | tests/frontend/interactive_init.py | 2 | ||||
-rw-r--r-- | tests/frontend/workspace.py | 14 | ||||
-rw-r--r-- | tests/internals/yaml.py | 34 |
17 files changed, 67 insertions, 62 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index c0e92b98e..8b559153e 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -233,11 +233,14 @@ class Context: # Load default config # - defaults = _yaml.load(_site.default_user_config) + defaults = _yaml.load(_site.default_user_config, shortname="userconfig.yaml") if config: self.config_origin = os.path.abspath(config) - user_config = _yaml.load(config) + + # Here we use the fullpath as the shortname as well, as it is useful to have + # a fullpath displayed in errors for the user configuration + user_config = _yaml.load(config, shortname=config) user_config._composite(defaults) # Give obsoletion warnings diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index ff68af66d..20914f15d 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -120,7 +120,7 @@ def complete_target(args, incomplete): else: project_file = os.path.join(base_directory, project_conf) try: - project = _yaml.load(project_file) + project = _yaml.load(project_file, shortname=project_conf) except LoadError: # If there is no project conf in context, just dont # even bother trying to complete anything. diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py index b45c6c695..76f30735a 100644 --- a/src/buildstream/_project.py +++ b/src/buildstream/_project.py @@ -747,11 +747,11 @@ class Project: # Load builtin default projectfile = os.path.join(self.directory, _PROJECT_CONF_FILE) - self._default_config_node = _yaml.load(_site.default_project_config) + self._default_config_node = _yaml.load(_site.default_project_config, shortname="projectconfig.yaml") # Load project local config and override the builtin try: - self._project_conf = _yaml.load(projectfile) + self._project_conf = _yaml.load(projectfile, shortname=_PROJECT_CONF_FILE, project=self) except LoadError as e: # Raise a more specific error here if e.reason == LoadErrorReason.MISSING_FILE: diff --git a/src/buildstream/_workspaces.py b/src/buildstream/_workspaces.py index a54a17ff1..f1fc353a7 100644 --- a/src/buildstream/_workspaces.py +++ b/src/buildstream/_workspaces.py @@ -449,7 +449,7 @@ class Workspaces: def _load_config(self): workspace_file = self._get_filename() try: - node = _yaml.load(workspace_file) + node = _yaml.load(workspace_file, shortname="workspaces.yml") except LoadError as e: if e.reason == LoadErrorReason.MISSING_FILE: # Return an empty dict if there was no workspace file diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx index 1e59b2a1c..17524cd1b 100644 --- a/src/buildstream/_yaml.pyx +++ b/src/buildstream/_yaml.pyx @@ -255,7 +255,7 @@ cdef class Representer: # # Raises: LoadError # -cpdef MappingNode load(str filename, str shortname=None, bint copy_tree=False, object project=None): +cpdef MappingNode load(str filename, str shortname, bint copy_tree=False, object project=None): cdef MappingNode data if not shortname: diff --git a/src/buildstream/testing/__init__.py b/src/buildstream/testing/__init__.py index f09c5bda1..19c19a64c 100644 --- a/src/buildstream/testing/__init__.py +++ b/src/buildstream/testing/__init__.py @@ -22,8 +22,7 @@ This package contains various utilities which make it easier to test plugins. import os from collections import OrderedDict from buildstream.exceptions import ErrorDomain, LoadErrorReason -from buildstream._yaml import load as load_yaml # type: ignore -from ._yaml import generate_project, generate_element +from ._yaml import generate_project, generate_element, load_yaml from .repo import Repo from .runcli import cli, cli_integration, cli_remote_execution from .integration import integration_cache diff --git a/src/buildstream/testing/_sourcetests/mirror.py b/src/buildstream/testing/_sourcetests/mirror.py index 69042747c..836ef0580 100644 --- a/src/buildstream/testing/_sourcetests/mirror.py +++ b/src/buildstream/testing/_sourcetests/mirror.py @@ -255,7 +255,7 @@ def test_mirror_track_upstream_present(cli, tmpdir, datafiles, kind): result.assert_success() # Tracking tries upstream first. Check the ref is from upstream. - new_element = _yaml.load(element_path) + new_element = _yaml.load(element_path, shortname=element_name) source = new_element.get_sequence("sources").mapping_at(0) if "ref" in source: assert source.get_str("ref") == upstream_ref @@ -300,7 +300,7 @@ def test_mirror_track_upstream_absent(cli, tmpdir, datafiles, kind): result.assert_success() # Check that tracking fell back to the mirror - new_element = _yaml.load(element_path) + new_element = _yaml.load(element_path, shortname=element_name) source = new_element.get_sequence("sources").mapping_at(0) if "ref" in source: assert source.get_str("ref") == mirror_ref diff --git a/src/buildstream/testing/_sourcetests/track.py b/src/buildstream/testing/_sourcetests/track.py index ecb508b1a..38ef217f0 100644 --- a/src/buildstream/testing/_sourcetests/track.py +++ b/src/buildstream/testing/_sourcetests/track.py @@ -284,7 +284,7 @@ def test_track_include(cli, tmpdir, datafiles, ref_storage, kind): else: assert not os.path.exists(os.path.join(project, "project.refs")) - new_sources = _yaml.load(os.path.join(element_path, "sources.yml")) + new_sources = _yaml.load(os.path.join(element_path, "sources.yml"), shortname="sources.yml") # Get all of the sources assert "sources" in new_sources diff --git a/src/buildstream/testing/_yaml.py b/src/buildstream/testing/_yaml.py index 0a16f3226..396266b85 100644 --- a/src/buildstream/testing/_yaml.py +++ b/src/buildstream/testing/_yaml.py @@ -1,6 +1,9 @@ import os +from buildstream import _yaml -from buildstream._yaml import roundtrip_dump # type: ignore + +def load_yaml(filename): + return _yaml.load(filename, shortname=os.path.basename(filename)) def generate_project(project_dir, config=None): @@ -11,11 +14,11 @@ def generate_project(project_dir, config=None): config["name"] = os.path.basename(project_dir) if "min-version" not in config: config["min-version"] = "2.0" - roundtrip_dump(config, project_file) + _yaml.roundtrip_dump(config, project_file) def generate_element(element_dir, element_name, config=None): if config is None: config = {} element_path = os.path.join(element_dir, element_name) - roundtrip_dump(config, element_path) + _yaml.roundtrip_dump(config, element_path) diff --git a/src/buildstream/testing/runcli.py b/src/buildstream/testing/runcli.py index 712e6811a..0f08bd141 100644 --- a/src/buildstream/testing/runcli.py +++ b/src/buildstream/testing/runcli.py @@ -539,7 +539,7 @@ class CliIntegration(Cli): with open(temp_project, "w") as f: yaml.safe_dump(project_config, f) - project_config = _yaml.load(temp_project) + project_config = _yaml.load(temp_project, shortname="project.conf") project_config._composite(base_config) diff --git a/tests/artifactcache/junctions.py b/tests/artifactcache/junctions.py index df7ee9473..18c48b4a7 100644 --- a/tests/artifactcache/junctions.py +++ b/tests/artifactcache/junctions.py @@ -16,7 +16,7 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "junctions" def project_set_artifacts(project, url): project_conf_file = os.path.join(project, "project.conf") - project_config = _yaml.load(project_conf_file) + project_config = _yaml.load(project_conf_file, shortname=None) project_config["artifacts"] = {"url": url, "push": True} _yaml.roundtrip_dump(project_config.strip_node_info(), file=project_conf_file) diff --git a/tests/elements/filter.py b/tests/elements/filter.py index 3bc24c20a..443f64d34 100644 --- a/tests/elements/filter.py +++ b/tests/elements/filter.py @@ -227,7 +227,7 @@ def test_filter_track(datafiles, cli, tmpdir): result.assert_success() # Now check that a ref field exists - new_input = _yaml.load(input_file) + new_input = _yaml.load(input_file, shortname=None) source_node = new_input.get_sequence("sources").mapping_at(0) new_input_ref = source_node.get_str("ref") assert new_input_ref == ref @@ -273,7 +273,7 @@ def test_filter_track_excepted(datafiles, cli, tmpdir): result.assert_success() # Now check that a ref field exists - new_input = _yaml.load(input_file) + new_input = _yaml.load(input_file, shortname=None) source_node = new_input.get_sequence("sources").mapping_at(0) assert "ref" not in source_node @@ -318,7 +318,7 @@ def test_filter_track_multi_to_one(datafiles, cli, tmpdir): result.assert_success() # Now check that a ref field exists - new_input = _yaml.load(input_file) + new_input = _yaml.load(input_file, shortname=None) source_node = new_input.get_sequence("sources").mapping_at(0) new_ref = source_node.get_str("ref") assert new_ref == ref @@ -374,12 +374,12 @@ def test_filter_track_multi(datafiles, cli, tmpdir): result.assert_success() # Now check that a ref field exists - new_input = _yaml.load(input_file) + new_input = _yaml.load(input_file, shortname=None) source_node = new_input.get_sequence("sources").mapping_at(0) new_ref = source_node.get_str("ref") assert new_ref == ref - new_input2 = _yaml.load(input2_file) + new_input2 = _yaml.load(input2_file, shortname=None) source_node2 = new_input2.get_sequence("sources").mapping_at(0) new_ref2 = source_node2.get_str("ref") assert new_ref2 == ref @@ -434,11 +434,11 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir): result.assert_success() # Now check that a ref field exists - new_input = _yaml.load(input_file) + new_input = _yaml.load(input_file, shortname=None) source_node = new_input.get_sequence("sources").mapping_at(0) assert "ref" not in source_node - new_input2 = _yaml.load(input2_file) + new_input2 = _yaml.load(input2_file, shortname=None) source_node2 = new_input2.get_sequence("sources").mapping_at(0) new_ref2 = source_node2.get_str("ref") assert new_ref2 == ref diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py index 3224822af..8148e18fa 100644 --- a/tests/format/include_composition.py +++ b/tests/format/include_composition.py @@ -23,7 +23,7 @@ def test_main_has_priority(tmpdir): _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": ["main"]}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml"))) @@ -36,7 +36,7 @@ def test_include_cannot_append(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": ["main"]}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": {"(>)": ["a"]}}, str(tmpdir.join("a.yml"))) @@ -49,7 +49,7 @@ def test_main_can_append(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml"], "test": {"(>)": ["main"]}}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml"))) @@ -62,7 +62,7 @@ def test_sibling_cannot_append_backward(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": {"(>)": ["a"]}}, str(tmpdir.join("a.yml"))) _yaml.roundtrip_dump({"test": ["b"]}, str(tmpdir.join("b.yml"))) @@ -76,7 +76,7 @@ def test_sibling_can_append_forward(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml"))) _yaml.roundtrip_dump({"test": {"(>)": ["b"]}}, str(tmpdir.join("b.yml"))) @@ -90,7 +90,7 @@ def test_lastest_sibling_has_priority(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml", "b.yml"]}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml"))) _yaml.roundtrip_dump({"test": ["b"]}, str(tmpdir.join("b.yml"))) @@ -104,7 +104,7 @@ def test_main_keeps_keys(tmpdir): with make_includes(str(tmpdir)) as includes: _yaml.roundtrip_dump({"(@)": ["a.yml"], "something": "else"}, str(tmpdir.join("main.yml"))) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) _yaml.roundtrip_dump({"test": ["a"]}, str(tmpdir.join("a.yml"))) @@ -121,7 +121,7 @@ def test_overwrite_directive_on_later_composite(tmpdir): {"(@)": ["a.yml", "b.yml"], "test": {"(=)": ["Overwritten"]}}, str(tmpdir.join("main.yml")) ) - main = _yaml.load(str(tmpdir.join("main.yml"))) + main = _yaml.load(str(tmpdir.join("main.yml")), shortname=None) # a.yml _yaml.roundtrip_dump( diff --git a/tests/frontend/init.py b/tests/frontend/init.py index 3f897fb14..c3af27bea 100644 --- a/tests/frontend/init.py +++ b/tests/frontend/init.py @@ -33,7 +33,7 @@ def test_defaults(cli, tmpdir): result = cli.run(args=["init", "--project-name", "foo", project]) result.assert_success() - project_conf = _yaml.load(project_path) + project_conf = _yaml.load(project_path, shortname=None) assert project_conf.get_str("name") == "foo" assert project_conf.get_str("min-version") == get_default_min_version() assert project_conf.get_str("element-path") == "elements" @@ -48,7 +48,7 @@ def test_all_options(cli, tmpdir): ) result.assert_success() - project_conf = _yaml.load(project_path) + project_conf = _yaml.load(project_path, shortname=None) assert project_conf.get_str("name") == "foo" assert project_conf.get_str("min-version") == "2.0" assert project_conf.get_str("element-path") == "ponies" @@ -81,7 +81,7 @@ def test_force_overwrite_project(cli, tmpdir): result = cli.run(args=["init", "--project-name", "foo", "--force", project]) result.assert_success() - project_conf = _yaml.load(project_path) + project_conf = _yaml.load(project_path, shortname=None) assert project_conf.get_str("name") == "foo" assert project_conf.get_str("min-version") == get_default_min_version() @@ -95,7 +95,7 @@ def test_relative_path_directory_as_argument(cli, tmpdir): result = cli.run(args=["init", "--project-name", "foo", rel_path]) result.assert_success() - project_conf = _yaml.load(project_path) + project_conf = _yaml.load(project_path, shortname=None) assert project_conf.get_str("name") == "foo" assert project_conf.get_str("min-version") == get_default_min_version() assert project_conf.get_str("element-path") == "elements" @@ -149,7 +149,7 @@ def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path): full_element_path = project.joinpath(element_path) assert full_element_path.exists() - project_conf = _yaml.load(str(project_conf_path)) + project_conf = _yaml.load(str(project_conf_path), shortname=None) assert project_conf.get_str("name") == "project_name" assert project_conf.get_str("min-version") == "2.0" assert project_conf.get_str("element-path") == element_path diff --git a/tests/frontend/interactive_init.py b/tests/frontend/interactive_init.py index b8cbe522f..c05fd4e37 100644 --- a/tests/frontend/interactive_init.py +++ b/tests/frontend/interactive_init.py @@ -36,7 +36,7 @@ def test_init(tmpdir): session.close() # Now assert that a project.conf got created with expected values - project_conf = _yaml.load(os.path.join(str(tmpdir), "project.conf")) + project_conf = _yaml.load(os.path.join(str(tmpdir), "project.conf"), shortname=None) assert project_conf.get_str("name") == name assert project_conf.get_str("min-version") == min_version assert project_conf.get_str("element-path") == element_path diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 4aae61ad7..813e68196 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -167,7 +167,7 @@ def test_open_bzr_customize(cli, tmpdir, datafiles): assert os.path.isdir(bzrdir) # Check that the correct origin branch is set - element_config = _yaml.load(os.path.join(project, "elements", element_name)) + element_config = _yaml.load(os.path.join(project, "elements", element_name), shortname=None) source_config = element_config.get_sequence("sources").mapping_at(0) output = subprocess.check_output(["bzr", "info"], cwd=workspace) stripped_url = source_config.get_str("url").lstrip("file:///") @@ -859,7 +859,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte def parse_dict_as_yaml(node): tempfile = os.path.join(str(tmpdir), "yaml_dump") _yaml.roundtrip_dump(node, tempfile) - return _yaml.load(tempfile).strip_node_info() + return _yaml.load(tempfile, shortname=None).strip_node_info() project = str(datafiles) os.makedirs(os.path.join(project, ".bst")) @@ -871,7 +871,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte result = cli.run(project=project, args=["workspace", "list"]) result.assert_success() - loaded_config = _yaml.load(workspace_config_path).strip_node_info() + loaded_config = _yaml.load(workspace_config_path, shortname=None).strip_node_info() # Check that workspace config remains the same if no modifications # to workspaces were made @@ -900,7 +900,7 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte result.assert_success() # Check that workspace config is converted correctly if necessary - loaded_config = _yaml.load(workspace_config_path).strip_node_info() + loaded_config = _yaml.load(workspace_config_path, shortname=None).strip_node_info() assert loaded_config == parse_dict_as_yaml(expected) @@ -1052,7 +1052,7 @@ def test_external_track(cli, datafiles, tmpdir_factory, guess_element): # Delete the ref from the source so that we can detect if the # element has been tracked after closing the workspace - element_contents = _yaml.load(element_file) + element_contents = _yaml.load(element_file, shortname=None) ref1 = element_contents.get_sequence("sources").mapping_at(0).get_str("ref") del element_contents.get_sequence("sources").mapping_at(0)["ref"] _yaml.roundtrip_dump(element_contents, element_file) @@ -1061,7 +1061,7 @@ def test_external_track(cli, datafiles, tmpdir_factory, guess_element): result.assert_success() # Element is not tracked now - element_contents = _yaml.load(element_file) + element_contents = _yaml.load(element_file, shortname=None) assert "ref" not in element_contents.get_sequence("sources").mapping_at(0) # close the workspace @@ -1072,7 +1072,7 @@ def test_external_track(cli, datafiles, tmpdir_factory, guess_element): result = cli.run(project=project, args=["source", "track", element_name]) result.assert_success() - element_contents = _yaml.load(element_file) + element_contents = _yaml.load(element_file, shortname=None) ref2 = element_contents.get_sequence("sources").mapping_at(0).get_str("ref") # these values should be equivalent assert ref1 == ref2 diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py index a4f8d08cc..4727d5d28 100644 --- a/tests/internals/yaml.py +++ b/tests/internals/yaml.py @@ -16,7 +16,7 @@ def test_load_yaml(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - loaded = _yaml.load(filename) + loaded = _yaml.load(filename, shortname=None) assert loaded.get_str("kind") == "pony" @@ -35,7 +35,7 @@ def test_basic_provenance(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - loaded = _yaml.load(filename) + loaded = _yaml.load(filename, shortname=None) assert loaded.get_str("kind") == "pony" assert_provenance(filename, 1, 0, loaded) @@ -46,7 +46,7 @@ def test_member_provenance(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - loaded = _yaml.load(filename) + loaded = _yaml.load(filename, shortname=None) assert loaded.get_str("kind") == "pony" assert_provenance(filename, 2, 13, loaded.get_scalar("description")) @@ -56,7 +56,7 @@ def test_element_provenance(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - loaded = _yaml.load(filename) + loaded = _yaml.load(filename, shortname=None) assert loaded.get_str("kind") == "pony" assert_provenance(filename, 5, 2, loaded.get_sequence("moods").scalar_at(1)) @@ -67,11 +67,11 @@ def test_mapping_validate_keys(datafiles): valid = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") invalid = os.path.join(datafiles.dirname, datafiles.basename, "invalid.yaml") - base = _yaml.load(valid) + base = _yaml.load(valid, shortname=None) base.validate_keys(["kind", "description", "moods", "children", "extra"]) - base = _yaml.load(invalid) + base = _yaml.load(invalid, shortname=None) with pytest.raises(LoadError) as exc: base.validate_keys(["kind", "description", "moods", "children", "extra"]) @@ -84,7 +84,7 @@ def test_node_get(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - base = _yaml.load(filename) + base = _yaml.load(filename, shortname=None) assert base.get_str("kind") == "pony" children = base.get_sequence("children") @@ -106,7 +106,7 @@ def test_node_set(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - base = _yaml.load(filename) + base = _yaml.load(filename, shortname=None) assert "mother" not in base base["mother"] = "snow white" @@ -118,7 +118,7 @@ def test_node_set_overwrite(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - base = _yaml.load(filename) + base = _yaml.load(filename, shortname=None) # Overwrite a string assert base.get_str("kind") == "pony" @@ -136,7 +136,7 @@ def test_node_set_list_element(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") - base = _yaml.load(filename) + base = _yaml.load(filename, shortname=None) assert base.get_str_list("moods") == ["happy", "sad"] base.get_sequence("moods")[0] = "confused" @@ -154,8 +154,8 @@ def test_composite_preserve_originals(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") overlayfile = os.path.join(datafiles.dirname, datafiles.basename, "composite.yaml") - base = _yaml.load(filename) - overlay = _yaml.load(overlayfile) + base = _yaml.load(filename, shortname=None) + overlay = _yaml.load(overlayfile, shortname=None) base_copy = base.clone() overlay._composite(base_copy) @@ -216,7 +216,7 @@ def test_list_composition(datafiles, filename, tmpdir, index, length, mood, prov base_file = os.path.join(datafiles.dirname, datafiles.basename, "basics.yaml") overlay_file = os.path.join(datafiles.dirname, datafiles.basename, filename) - base = _yaml.load(base_file, "basics.yaml") + base = _yaml.load(base_file, shortname="basics.yaml") overlay = _yaml.load(overlay_file, shortname=filename) overlay._composite(base) @@ -369,7 +369,7 @@ def test_convert_value_to_string(datafiles): conf_file = os.path.join(datafiles.dirname, datafiles.basename, "convert_value_to_str.yaml") # Run file through yaml to convert it - test_dict = _yaml.load(conf_file) + test_dict = _yaml.load(conf_file, shortname=None) user_config = test_dict.get_str("Test1") assert isinstance(user_config, str) @@ -393,7 +393,7 @@ def test_value_doesnt_match_expected(datafiles): conf_file = os.path.join(datafiles.dirname, datafiles.basename, "convert_value_to_str.yaml") # Run file through yaml to convert it - test_dict = _yaml.load(conf_file) + test_dict = _yaml.load(conf_file, shortname=None) with pytest.raises(LoadError) as exc: test_dict.get_int("Test4") @@ -445,7 +445,7 @@ def test_node_find_target(datafiles, case): filename = os.path.join(datafiles.dirname, datafiles.basename, "traversal.yaml") # We set copy_tree in order to ensure that the nodes in `loaded` # are not the same nodes as in `prov.toplevel` - loaded = _yaml.load(filename, copy_tree=True) + loaded = _yaml.load(filename, shortname=None, copy_tree=True) prov = loaded.get_provenance() @@ -477,7 +477,7 @@ def test_node_find_target(datafiles, case): @pytest.mark.datafiles(os.path.join(DATA_DIR)) def test_node_find_target_fails(datafiles): filename = os.path.join(datafiles.dirname, datafiles.basename, "traversal.yaml") - loaded = _yaml.load(filename, copy_tree=True) + loaded = _yaml.load(filename, shortname=None, copy_tree=True) brand_new = Node.from_dict({}) |