Esempio n. 1
0
def test_file():
    p = '/tmp/scruffy_test_file'
    f = File(p)
    safe_unlink(p)
    assert not os.path.exists(p)
    f.create()
    assert os.path.exists(p)
Esempio n. 2
0
def test_lock_file():
    p = '/tmp/scruffy_test_file'
    safe_unlink(p)
    assert not os.path.exists(p)
    with LockFile(p):
        assert os.path.exists(p)
    assert not os.path.exists(p)
    f = File(p)
    f.create()
    try:
        with LockFile(p):
            assert False
    except:
        assert True
    f.remove()
    assert not os.path.exists(p)