def test_to_basic_invalid(self): field = BytesField(name='asdf') field.encoding = 'adsf' with pytest.raises(TypeError): field.to_basic(MockConfig(), 'asdf')
def test_to_basic_hex(self): field = BytesField('hex') assert field.to_basic(MockConfig(), b'hello') == b'hello'.hex()
def test_to_basic_base64(self): field = BytesField('base64') assert field.to_basic(MockConfig(), b'hello') == base64.b64encode(b'hello').decode()
def test_to_basic_none(self): field = BytesField(name='asdf') field.to_basic(MockConfig(), None) is None
def test_to_basic_hex(self): field = BytesField('hex') assert field.to_basic(None, b'hello') == b'hello'.hex()
def test_to_basic_none(self): field = BytesField(name='asdf') field.to_basic(None, None) is None