Exemplo n.º 1
0
def test_tmppath():
    path = temps.tmppath()
    assert not os.path.exists(path)
    try:
        os.mkdir(path)
    finally:
        if os.path.isdir(path):
            os.rmdir(path)
Exemplo n.º 2
0
def test_tmppath():
    path = temps.tmppath()
    assert not os.path.exists(path)
    try:
        os.mkdir(path)
    finally:
        if os.path.isdir(path):
            os.rmdir(path)
Exemplo n.º 3
0
def dump(msg, filename=None):
    '''
    Write a message to a file.  If filename is None, a unique hexadecimal
    temporary filename will be used.  Either way, the filename is returned, so
    it can be communicated to whoever will read the file.
    '''
    if filename is None:
        filename = temps.tmppath()

    with open(filename, 'wb') as fh:
        pickle.dump(msg, fh, pickle.HIGHEST_PROTOCOL)

    return filename