コード例 #1
0
ファイル: ex23_lamson.py プロジェクト: bdebelle/learnpython
def test_to_file_from_file():
    mb = mailbox.mbox("tests/spam")
    msg = encoding.from_message(mb[0])

    outfile = "run/encoding_test.msg"

    with open(outfile, 'w') as outfp:
        encoding.to_file(msg, outfp)

    with open(outfile) as outfp:
        msg2 = encoding.from_file(outfp)
    
    outdata = open(outfile).read()

    assert_equal(len(msg), len(msg2))
    os.unlink(outfile)
コード例 #2
0
ファイル: encoding_tests.py プロジェクト: ilg/lamson-bsd
def test_to_file_from_file():
    mb = mailbox.mbox("tests/spam")
    msg = encoding.from_message(mb[0])

    outfile = "run/encoding_test.msg"

    with open(outfile, 'w') as outfp:
        encoding.to_file(msg, outfp)

    with open(outfile) as outfp:
        msg2 = encoding.from_file(outfp)

    outdata = open(outfile).read()

    assert_equal(len(msg), len(msg2))
    os.unlink(outfile)
コード例 #3
0
ファイル: ex23_lamson.py プロジェクト: bdebelle/learnpython
def test_content_encoding_headers_are_maintained():
    inmail = encoding.from_file(open("tests/signed.msg"))

    ctype, ctype_params = inmail.content_encoding['Content-Type']

    assert_equal(ctype, 'multipart/signed')

    # these have to be maintained
    for key in ['protocol', 'micalg']:
        assert key in ctype_params

    # these get removed
    for key in encoding.CONTENT_ENCODING_REMOVED_PARAMS:
        assert key not in ctype_params

    outmsg = encoding.to_message(inmail)
    ctype, ctype_params = encoding.parse_parameter_header(outmsg, 'Content-Type')
    for key in ['protocol', 'micalg']:
        assert key in ctype_params, key
コード例 #4
0
ファイル: encoding_tests.py プロジェクト: vsajip/lamson
def test_content_encoding_headers_are_maintained():
    inmail = encoding.from_file(open("tests/signed.msg"))

    ctype, ctype_params = inmail.content_encoding['Content-Type']

    assert_equal(ctype, 'multipart/signed')

    # these have to be maintained
    for key in ['protocol', 'micalg']:
        assert key in ctype_params

    # these get removed
    for key in encoding.CONTENT_ENCODING_REMOVED_PARAMS:
        assert key not in ctype_params

    outmsg = encoding.to_message(inmail)
    ctype, ctype_params = encoding.parse_parameter_header(outmsg, 'Content-Type')
    for key in ['protocol', 'micalg']:
        assert key in ctype_params, key
コード例 #5
0
ファイル: ex23_lamson.py プロジェクト: bdebelle/learnpython
def test_to_message_encoding_error(mp_init):
    mp_init.side_effect = raises_TypeError
    test = encoding.from_file(open("tests/borked.msg"))
    msg = encoding.to_message(test)
コード例 #6
0
ファイル: ex23_lamson.py プロジェクト: bdebelle/learnpython
def test_specially_borked_lua_message():
    assert encoding.from_file(open("tests/borked.msg"))
コード例 #7
0
ファイル: encoding_tests.py プロジェクト: ilg/lamson-bsd
def test_to_message_encoding_error(mp_init):
    mp_init.side_effect = raises_TypeError
    test = encoding.from_file(open("tests/borked.msg"))
    msg = encoding.to_message(test)
コード例 #8
0
ファイル: encoding_tests.py プロジェクト: ilg/lamson-bsd
def test_specially_borked_lua_message():
    assert encoding.from_file(open("tests/borked.msg"))