diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-06-10 07:51:57 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-15 14:14:02 +0000 |
commit | 38671fb53f4522d046bed94699db8cc344ac2862 (patch) | |
tree | dc75c432d897d393d3a568290d45d762c7bde093 /tests/sources/git.py | |
parent | fcef3658433f74a2f396ed353bb3534f0001f3d8 (diff) | |
download | buildstream-38671fb53f4522d046bed94699db8cc344ac2862.tar.gz |
_yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNode
- 'get_scalar()' allows retrieving a scalar node from a mapping.
- 'as_str()' casts a ScalarNode into a string (thus removing the node
information).
Both together, those replace 'node_get(mapping, key, type=str)' but
also allow retrieving the 'Node' itself, which will allow in the future
lazier provenance computation.
Diffstat (limited to 'tests/sources/git.py')
-rw-r--r-- | tests/sources/git.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py index 45a2b827a..2b8a12997 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -760,7 +760,7 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): result.assert_success() element = _yaml.load(element_path) - new_ref = _yaml.node_get(_yaml.node_get(element, dict, 'sources', [0]), str, 'ref') + new_ref = _yaml.node_get(element, dict, 'sources', [0]).get_str('ref') if ref_format == 'git-describe' and tag: # Check and strip prefix @@ -857,8 +857,8 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): assert 'annotated' in tag assert _yaml.node_get(tag, bool, 'annotated') == (tag_type == 'annotated') - assert {(_yaml.node_get(tag, str, 'tag'), - _yaml.node_get(tag, str, 'commit')) + assert {(tag.get_str('tag'), + tag.get_str('commit')) for tag in tags} == {('tag1', repo.rev_parse('tag1^{commit}')), ('tag2', repo.rev_parse('tag2^{commit}'))} @@ -972,8 +972,8 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty assert 'annotated' in tag assert _yaml.node_get(tag, bool, 'annotated') == (tag_type == 'annotated') - tag_name = _yaml.node_get(tag, str, 'tag') - commit = _yaml.node_get(tag, str, 'commit') + tag_name = tag.get_str('tag') + commit = tag.get_str('commit') assert (tag_name, commit) == ('tag', repo.rev_parse('tag^{commit}')) checkout = os.path.join(str(tmpdir), 'checkout') |