コード例 #1
0
ファイル: test_tempfiles.py プロジェクト: janvdvegt/kopf
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)
コード例 #2
0
ファイル: test_tempfiles.py プロジェクト: janvdvegt/kopf
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)
コード例 #3
0
ファイル: test_tempfiles.py プロジェクト: janvdvegt/kopf
def test_created():
    tempfiles = _TempFiles()
    path = tempfiles[b'hello']
    assert os.path.isfile(path)
    assert open(path, 'rb').read() == b'hello'
コード例 #4
0
ファイル: test_tempfiles.py プロジェクト: janvdvegt/kopf
def test_differs():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'world']
    assert path1 != path2
コード例 #5
0
ファイル: test_tempfiles.py プロジェクト: janvdvegt/kopf
def test_reused():
    tempfiles = _TempFiles()
    path1 = tempfiles[b'hello']
    path2 = tempfiles[b'hello']
    assert path1 == path2