Пример #1
0
def test_lockmanager_release_all_suppress_filenotfounderror(nlocks, tmpdir):
    lockman = LockManager()
    dir_template = 'dir{}'

    for n in range(nlocks):
        try:
            path = tmpdir.mkdir(dir_template.format(n))
            lockman.lock(str(path))
        except OSError:
            raise

        try:
            path.join(lockman.filename).remove()
        except OSError:
            raise

    try:
        lockman.release_all()
    except FileNotFoundError:
        pytest.fail('LockManager.release_all raised a FileNotFoundError.')
    except OSError:
        raise
    else:
        assert len(lockman.locks) is 0
Пример #2
0
def test_lockmanager_release_all(nlocks, tmpdir):
    lockman = LockManager()
    dir_template = 'dir{}'

    lock_list = []

    for n in range(nlocks):
        try:
            path = tmpdir.mkdir(dir_template.format(n))
            lockman.lock(str(path))
        except OSError:
            raise
        else:
            lock_list.append(join(str(path), lockman.filename))

    try:
        lockman.release_all()
    except OSError:
        raise
    else:
        assert len(lockman.locks) is 0

    for l in lock_list:
        assert not isfile(l)