def test_bad_intpacker(): with pytest.raises(ValueError): int_packer.packinteger('python') with pytest.raises(ValueError): int_packer.unpackinteger('python') with pytest.raises(ValueError): int_packer.unpackinteger('fffa') with pytest.raises(ValueError): int_packer.packinteger(45, 'python')
def test_intpacker_return_bytes(val, ex): packed = int_packer.packinteger(val, bytes)
def test_lossy_intpacker(val, ex, err): packed = int_packer.packinteger(val) assert packed == ex unpacked = int_packer.unpackinteger(packed) assert abs(unpacked - val) < err
def test_intpacker(val, ex): packed = int_packer.packinteger(val) assert packed == ex unpacked = int_packer.unpackinteger(packed) assert unpacked == val