Beispiel #1
0
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')
Beispiel #2
0
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')
Beispiel #3
0
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
Beispiel #4
0
def test_intpacker(val, ex):
    packed = int_packer.packinteger(val)
    assert packed == ex
    unpacked = int_packer.unpackinteger(packed)
    assert unpacked == val
Beispiel #5
0
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
Beispiel #6
0
def test_intpacker(val, ex):
    packed = int_packer.packinteger(val)
    assert packed == ex
    unpacked = int_packer.unpackinteger(packed)
    assert unpacked == val