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')
def test_encode_metadata_invalid_key(key): with pytest.raises(ValueError) as err: encode_metadata({key: 'anything'}) err.match('Invalid metadata key')
def test_encode_metadata(value, output): assert encode_metadata(value) == output
def test_encode_metadata_invalid_value(value): with pytest.raises(ValueError) as err: encode_metadata({'foo': value}) err.match('Invalid metadata value')