コード例 #1
0
def test_uu():
    assert binascii.b2a_uu('1234567') == "',3(S-#4V-P  \n"
    assert binascii.b2a_uu('123456789012345678901234567890123456789012345') == 'M,3(S-#4V-S@Y,#$R,S0U-C<X.3 Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U\n'
    try:
        assert binascii.b2a_uu('1234567890123456789012345678901234567890123456')
    except binascii.Error:
        pass
    else:
        assert False, "Expected binascii.Error on oversize input."
    assert binascii.b2a_uu('1234567') == "',3(S-#4V-P  \n"
    assert binascii.b2a_uu('123456789012345678901234567890123456789012345')  == 'M,3(S-#4V-S@Y,#$R,S0U-C<X.3 Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U\n'
コード例 #2
0
def test_uu():
    MAX_UU = 45
    lines = []
    for i in range(0, len(data), MAX_UU):
        b = data[i:i + MAX_UU]
        a = binascii.b2a_uu(b)
        lines.append(a)
    res = ""
    for line in lines:
        b = binascii.a2b_uu(line)
        res += b
    assert res == data

    assert binascii.a2b_uu("\x7f") == "\x00" * 31
    assert binascii.a2b_uu("\x80") == "\x00" * 32
    assert binascii.a2b_uu("\xff") == "\x00" * 31
    py.test.raises(binascii.Error, binascii.a2b_uu, "\xff\x00")
    py.test.raises(binascii.Error, binascii.a2b_uu, "!!!!")

    py.test.raises(binascii.Error, binascii.b2a_uu, 46 * "!")
コード例 #3
0
ファイル: test_binascii.py プロジェクト: cha0s-repo/pypy
def test_uu():
    MAX_UU = 45
    lines = []
    for i in range(0, len(data), MAX_UU):
        b = data[i:i+MAX_UU]
        a = binascii.b2a_uu(b)
        lines.append(a)
    res = ""
    for line in lines:
        b = binascii.a2b_uu(line)
        res += b
    assert res == data

    assert binascii.a2b_uu("\x7f") == "\x00"*31
    assert binascii.a2b_uu("\x80") == "\x00"*32
    assert binascii.a2b_uu("\xff") == "\x00"*31
    py.test.raises(binascii.Error, binascii.a2b_uu, "\xff\x00")
    py.test.raises(binascii.Error, binascii.a2b_uu, "!!!!")

    py.test.raises(binascii.Error, binascii.b2a_uu, 46*"!")