Exemplo n.º 1
0
def test_encode():
    s = b'hello world'
    looseb = b''.join(git._encode_looseobj(b'blob', s))
    looset = b''.join(git._encode_looseobj(b'tree', s))
    loosec = b''.join(git._encode_looseobj(b'commit', s))
    packb = b''.join(git._encode_packobj(b'blob', s))
    packt = b''.join(git._encode_packobj(b'tree', s))
    packc = b''.join(git._encode_packobj(b'commit', s))
    packlb = b''.join(git._encode_packobj(b'blob', s * 200))
    WVPASSEQ(git._decode_looseobj(looseb), (b'blob', s))
    WVPASSEQ(git._decode_looseobj(looset), (b'tree', s))
    WVPASSEQ(git._decode_looseobj(loosec), (b'commit', s))
    WVPASSEQ(git._decode_packobj(packb), (b'blob', s))
    WVPASSEQ(git._decode_packobj(packt), (b'tree', s))
    WVPASSEQ(git._decode_packobj(packc), (b'commit', s))
    WVPASSEQ(git._decode_packobj(packlb), (b'blob', s * 200))
    for i in range(10):
        WVPASS(git._encode_looseobj(b'blob', s, compression_level=i))

    def encode_pobj(n):
        return b''.join(git._encode_packobj(b'blob', s, compression_level=n))

    WVEXCEPT(ValueError, encode_pobj, -1)
    WVEXCEPT(ValueError, encode_pobj, 10)
    WVEXCEPT(ValueError, encode_pobj, b'x')
Exemplo n.º 2
0
def testencode():
    with no_lingering_errors():
        s = b'hello world'

        def decode_packobj(data):
            it = git._decode_packobj(data)
            tp, sz = next(it)
            return (tp, b''.join(it))

        packb = b''.join(git._encode_packobj(b'blob', s))
        packt = b''.join(git._encode_packobj(b'tree', s))
        packc = b''.join(git._encode_packobj(b'commit', s))
        packlb = b''.join(git._encode_packobj(b'blob', s * 200))
        WVPASSEQ(decode_packobj(packb), (b'blob', s))
        WVPASSEQ(decode_packobj(packt), (b'tree', s))
        WVPASSEQ(decode_packobj(packc), (b'commit', s))
        WVPASSEQ(decode_packobj(packlb), (b'blob', s * 200))

        def encode_pobj(n):
            return b''.join(
                git._encode_packobj(b'blob', s, compression_level=n))

        WVEXCEPT(ValueError, encode_pobj, -2)
        WVEXCEPT(ValueError, encode_pobj, 10)
        WVEXCEPT(ValueError, encode_pobj, b'x')
Exemplo n.º 3
0
def testencode():
    s = 'hello world'
    looseb = ''.join(git._encode_looseobj('blob', s))
    looset = ''.join(git._encode_looseobj('tree', s))
    loosec = ''.join(git._encode_looseobj('commit', s))
    packb = ''.join(git._encode_packobj('blob', s))
    packt = ''.join(git._encode_packobj('tree', s))
    packc = ''.join(git._encode_packobj('commit', s))
    WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
    WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
    WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
    WVPASSEQ(git._decode_packobj(packb), ('blob', s))
    WVPASSEQ(git._decode_packobj(packt), ('tree', s))
    WVPASSEQ(git._decode_packobj(packc), ('commit', s))
Exemplo n.º 4
0
Arquivo: tgit.py Projeto: senseb/bup
def testencode():
    s = 'hello world'
    looseb = ''.join(git._encode_looseobj('blob', s))
    looset = ''.join(git._encode_looseobj('tree', s))
    loosec = ''.join(git._encode_looseobj('commit', s))
    packb = ''.join(git._encode_packobj('blob', s))
    packt = ''.join(git._encode_packobj('tree', s))
    packc = ''.join(git._encode_packobj('commit', s))
    WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
    WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
    WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
    WVPASSEQ(git._decode_packobj(packb), ('blob', s))
    WVPASSEQ(git._decode_packobj(packt), ('tree', s))
    WVPASSEQ(git._decode_packobj(packc), ('commit', s))
Exemplo n.º 5
0
def testencode():
    with no_lingering_errors():
        s = 'hello world'
        looseb = ''.join(git._encode_looseobj('blob', s))
        looset = ''.join(git._encode_looseobj('tree', s))
        loosec = ''.join(git._encode_looseobj('commit', s))
        packb = ''.join(git._encode_packobj('blob', s))
        packt = ''.join(git._encode_packobj('tree', s))
        packc = ''.join(git._encode_packobj('commit', s))
        WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
        WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
        WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
        WVPASSEQ(git._decode_packobj(packb), ('blob', s))
        WVPASSEQ(git._decode_packobj(packt), ('tree', s))
        WVPASSEQ(git._decode_packobj(packc), ('commit', s))
        for i in xrange(10):
            WVPASS(git._encode_looseobj('blob', s, compression_level=i))
        def encode_pobj(n):
            return ''.join(git._encode_packobj('blob', s, compression_level=n))
        WVEXCEPT(ValueError, encode_pobj, -1)
        WVEXCEPT(ValueError, encode_pobj, 10)
        WVEXCEPT(ValueError, encode_pobj, 'x')
Exemplo n.º 6
0
Arquivo: tgit.py Projeto: zzmjohn/bup
 def encode_pobj(n):
     return b''.join(git._encode_packobj(b'blob', s, compression_level=n))
Exemplo n.º 7
0
 def encode_pobj(n):
     return ''.join(git._encode_packobj('blob', s, compression_level=n))