Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_is_locked(get_lock_filepath):
- test_path = get_lock_filepath
- plock = lock.ProcessLock("./randompath/lockfile")
- assert plock.is_locked() is False
- plock.path = test_path
- with open(test_path, 'w') as f:
- f.write("")
- assert plock.is_locked() is False
- with open(test_path, 'w') as f:
- f.write("dfsdf")
- pytest.raises(ValueError, plock.is_locked)
- with open(test_path, 'w') as f:
- f.write("1234")
- assert plock.is_locked() is False
- with open(test_path, 'w') as f:
- f.write(str(os.getpid()))
- assert plock.is_locked() is True
- # any other cases that make sense ///
- os.remove(test_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement