def test_yaml_load_no_base(): with pytest.raises(errors.LegacyFallback) as raised: yaml_utils.load( io.StringIO(dedent("""\ entry: foo """))) assert str(raised.value) == "no base defined"
def test_yaml_load_not_core22_base(): with pytest.raises(errors.LegacyFallback) as raised: yaml_utils.load( io.StringIO(dedent("""\ base: core20 """))) assert str(raised.value) == "base is not core22"
def test_yaml_load_unhashable_errors(): with pytest.raises(errors.SnapcraftError) as raised: yaml_utils.load( io.StringIO( dedent("""\ base: core22 entry: {{value}} """))) assert str(raised.value) == dedent("""\ snapcraft.yaml parsing error: while constructing a mapping in "<file>", line 2, column 8 found unhashable key in "<file>", line 2, column 9""")
def test_yaml_load_duplicates_errors(): with pytest.raises(errors.SnapcraftError) as raised: yaml_utils.load( io.StringIO( dedent("""\ base: core22 entry: value1 entry: value2 """))) assert str(raised.value) == dedent("""\ snapcraft.yaml parsing error: while constructing a mapping found duplicate key 'entry' in "<file>", line 1, column 1""")
def test_yaml_load_build_base(): assert (yaml_utils.load( io.StringIO( dedent("""\ base: foo build-base: core22 """))) == { "base": "foo", "build-base": "core22", })
def test_yaml_load(): assert (yaml_utils.load( io.StringIO( dedent("""\ base: core22 entry: sub-entry: - list1 - list2 scalar: scalar-value """))) == { "base": "core22", "entry": { "sub-entry": ["list1", "list2"], }, "scalar": "scalar-value", })