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)
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)
def test_created(): tempfiles = _TempFiles() path = tempfiles[b'hello'] assert os.path.isfile(path) assert open(path, 'rb').read() == b'hello'
def test_differs(): tempfiles = _TempFiles() path1 = tempfiles[b'hello'] path2 = tempfiles[b'world'] assert path1 != path2
def test_reused(): tempfiles = _TempFiles() path1 = tempfiles[b'hello'] path2 = tempfiles[b'hello'] assert path1 == path2