Beispiel #1
0
    def test_serialize_yaml(self):
        data = {"foo": "bar", "encrypted_data": EncryptedString("foo")}
        serialized = yaml.serialize(data)
        assert serialized == '{encrypted_data: !encrypted foo, foo: bar}', serialized

        deserialized = yaml.deserialize(serialized)
        assert deserialized == data, deserialized
Beispiel #2
0
    def test_serialize_yaml(self):
        data = {"foo": "bar", "encrypted_data": EncryptedString("foo")}
        # The C dumper produces unquoted strings when serializing an
        # EncryptedString, while the non-C dumper produces quoted strings.
        expected = '{encrypted_data: !encrypted foo, foo: bar}' \
            if hasattr(_yaml, 'CSafeDumper') \
            else "{encrypted_data: !encrypted 'foo', foo: bar}"
        serialized = yaml.serialize(data)
        assert serialized == expected, serialized

        deserialized = yaml.deserialize(serialized)
        assert deserialized == data, deserialized