Beispiel #1
0
def test_purged():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'world']
    assert os.path.isfile(path1)
    assert os.path.isfile(path2)

    tempfiles.purge()

    assert not os.path.isfile(path1)
    assert not os.path.isfile(path2)
Beispiel #2
0
def test_garbage_collected():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'world']
    assert os.path.isfile(path1)
    assert os.path.isfile(path2)

    del tempfiles
    gc.collect()
    gc.collect()
    gc.collect()

    assert not os.path.isfile(path1)
    assert not os.path.isfile(path2)
Beispiel #3
0
def test_created():
    tempfiles = _TempFiles()
    path = tempfiles[b'hello']
    assert os.path.isfile(path)
    assert open(path, 'rb').read() == b'hello'
Beispiel #4
0
def test_differs():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'world']
    assert path1 != path2
Beispiel #5
0
def test_reused():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'hello']
    assert path1 == path2