diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-07-08 14:18:39 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:03 +0000 |
commit | 099e3ebf3aad424be2f3488aef9d9d961b700483 (patch) | |
tree | b1634644122751537e092caf8c35f8a1cee6cf9b /tests | |
parent | 695eddc069c9803eca5d004e80ca7be7defdd20c (diff) | |
download | buildstream-099e3ebf3aad424be2f3488aef9d9d961b700483.tar.gz |
_yaml: Remove 'node_get_provenance' and add 'Node.get_provenance'
This replaces the helper method by adding a 'get_provenance' on the node
directly
- Adapt all call sites
- Delay getting provenance wherever possible without major refactor
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/buildcheckout.py | 2 | ||||
-rw-r--r-- | tests/frontend/fetch.py | 2 | ||||
-rw-r--r-- | tests/frontend/show.py | 2 | ||||
-rw-r--r-- | tests/frontend/track.py | 4 | ||||
-rw-r--r-- | tests/internals/yaml.py | 16 |
5 files changed, 13 insertions, 13 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 07ebe7e6a..d3eec0d21 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -462,7 +462,7 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage): # Assert that we have the expected provenance encoded into the error element_node = _yaml.load(element_path, shortname='junction-dep.bst') ref_node = element_node.get_sequence('depends').mapping_at(0) - provenance = _yaml.node_get_provenance(ref_node) + provenance = ref_node.get_provenance() assert str(provenance) in result.stderr diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py index ba79dcfd1..7ea357ac2 100644 --- a/tests/frontend/fetch.py +++ b/tests/frontend/fetch.py @@ -172,5 +172,5 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage): # Assert that we have the expected provenance encoded into the error element_node = _yaml.load(element_path, shortname='junction-dep.bst') ref_node = element_node.get_sequence('depends').mapping_at(0) - provenance = _yaml.node_get_provenance(ref_node) + provenance = ref_node.get_provenance() assert str(provenance) in result.stderr diff --git a/tests/frontend/show.py b/tests/frontend/show.py index a0421bd37..756fe1786 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -335,7 +335,7 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage, workspaced): # Assert that we have the expected provenance encoded into the error element_node = _yaml.load(element_path, shortname='junction-dep.bst') ref_node = element_node.get_sequence('depends').mapping_at(0) - provenance = _yaml.node_get_provenance(ref_node) + provenance = ref_node.get_provenance() assert str(provenance) in dep_result.stderr dep_result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.SUBPROJECT_INCONSISTENT) diff --git a/tests/frontend/track.py b/tests/frontend/track.py index b8ab0d4eb..a628043d8 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -277,7 +277,7 @@ def test_inconsistent_junction(cli, tmpdir, datafiles, ref_storage): # Assert that we have the expected provenance encoded into the error element_node = _yaml.load(element_path, shortname='junction-dep.bst') ref_node = element_node.get_sequence('depends').mapping_at(0) - provenance = _yaml.node_get_provenance(ref_node) + provenance = ref_node.get_provenance() assert str(provenance) in result.stderr @@ -316,7 +316,7 @@ def test_junction_element(cli, tmpdir, datafiles, ref_storage): # Assert that we have the expected provenance encoded into the error element_node = _yaml.load(element_path, shortname='junction-dep.bst') ref_node = element_node.get_sequence('depends').mapping_at(0) - provenance = _yaml.node_get_provenance(ref_node) + provenance = ref_node.get_provenance() assert str(provenance) in result.stderr # Now track the junction itself diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py index 8ceed9d15..9e62cdcb3 100644 --- a/tests/internals/yaml.py +++ b/tests/internals/yaml.py @@ -24,8 +24,8 @@ def test_load_yaml(datafiles): assert loaded.get_str('kind') == 'pony' -def assert_provenance(filename, line, col, node, key=None): - provenance = _yaml.node_get_provenance(node, key=key) +def assert_provenance(filename, line, col, node): + provenance = node.get_provenance() assert isinstance(provenance, _yaml.ProvenanceInformation) @@ -56,7 +56,7 @@ def test_member_provenance(datafiles): loaded = _yaml.load(filename) assert loaded.get_str('kind') == 'pony' - assert_provenance(filename, 2, 13, loaded, 'description') + assert_provenance(filename, 2, 13, loaded.get_scalar('description')) @pytest.mark.datafiles(os.path.join(DATA_DIR)) @@ -108,7 +108,7 @@ def test_node_get(datafiles): assert len(children) == 7 child = base.get_sequence('children').mapping_at(6) - assert_provenance(filename, 20, 8, child, 'mood') + assert_provenance(filename, 20, 8, child.get_scalar('mood')) extra = base.get_mapping('extra') with pytest.raises(LoadError) as exc: @@ -256,7 +256,7 @@ def test_list_composition(datafiles, filename, tmpdir, child = children.mapping_at(index) assert child.get_str('mood') == mood - assert_provenance(prov_file, prov_line, prov_col, child, 'mood') + assert_provenance(prov_file, prov_line, prov_col, child.get_node('mood')) # Test that overwriting a list with an empty list works as expected. @@ -378,7 +378,7 @@ def test_list_composition_twice(datafiles, tmpdir, filename1, filename2, child = children.mapping_at(index) assert child.get_str('mood') == mood - assert_provenance(prov_file, prov_line, prov_col, child, 'mood') + assert_provenance(prov_file, prov_line, prov_col, child.get_node('mood')) ##################### # Round 2 - Fight ! @@ -395,7 +395,7 @@ def test_list_composition_twice(datafiles, tmpdir, filename1, filename2, child = children.mapping_at(index) assert child.get_str('mood') == mood - assert_provenance(prov_file, prov_line, prov_col, child, 'mood') + assert_provenance(prov_file, prov_line, prov_col, child.get_node('mood')) @pytest.mark.datafiles(os.path.join(DATA_DIR)) @@ -494,7 +494,7 @@ def test_node_find_target(datafiles, case): # are not the same nodes as in `prov.toplevel` loaded = _yaml.load(filename, copy_tree=True) - prov = _yaml.node_get_provenance(loaded) + prov = loaded.get_provenance() toplevel = prov.toplevel |