예제 #1
0
def test_fileobject_tmppath_no_file(tmpdir):

    path = tmpdir.join('fileobject-tmppath-no-file')
    fo = FileObject(str(path))
    assert fo.path == path

    fo.mktemp()
    assert fo.path.endswith('fileobject-tmppath-no-file.part')
    assert not os.path.exists(fo.path)

    fo.rmtemp()
    assert fo.path.endswith('fileobject-tmppath-no-file')
    assert not os.path.exists(fo.path)
예제 #2
0
def test_fileobject_tmppath_with_file(tmpdir):

    path = tmpdir.join('fileobject-tmppath-with-file')
    fo = FileObject(str(path))
    assert fo.path == path

    fo.write('fileobject-tmppath-with-file')
    assert fo.read() == 'fileobject-tmppath-with-file'

    fo.mktemp()
    assert fo.path.endswith('fileobject-tmppath-with-file.part')
    assert os.path.exists(fo.path)

    fo.rmtemp()
    assert fo.path.endswith('fileobject-tmppath-with-file')
    assert os.path.exists(fo.path)