Example #1
0
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"
Example #2
0
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"
Example #3
0
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""")
Example #4
0
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""")
Example #5
0
def test_yaml_load_build_base():
    assert (yaml_utils.load(
        io.StringIO(
            dedent("""\
        base: foo
        build-base: core22
    """))) == {
                "base": "foo",
                "build-base": "core22",
            })
Example #6
0
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",
            })