Пример #1
0
def test_encode_metadata_errors():
    with pytest.raises(TypeError) as e1:
        encode_metadata({'regular': b'invalid'})
    e1.match('Invalid metadata value type, str expected')

    with pytest.raises(TypeError) as e2:
        encode_metadata({'binary-bin': 'invalid'})
    e2.match('Invalid metadata value type, bytes expected')
Пример #2
0
def test_encode_metadata_invalid_key(key):
    with pytest.raises(ValueError) as err:
        encode_metadata({key: 'anything'})
    err.match('Invalid metadata key')
Пример #3
0
def test_encode_metadata(value, output):
    assert encode_metadata(value) == output
Пример #4
0
def test_encode_metadata_invalid_value(value):
    with pytest.raises(ValueError) as err:
        encode_metadata({'foo': value})
    err.match('Invalid metadata value')