Advertisement
Guest User

Untitled

a guest
May 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. def test_is_locked(get_lock_filepath):
  2. test_path = get_lock_filepath
  3.  
  4. plock = lock.ProcessLock("./randompath/lockfile")
  5. assert plock.is_locked() is False
  6.  
  7. plock.path = test_path
  8. with open(test_path, 'w') as f:
  9. f.write("")
  10. assert plock.is_locked() is False
  11.  
  12. with open(test_path, 'w') as f:
  13. f.write("dfsdf")
  14. pytest.raises(ValueError, plock.is_locked)
  15.  
  16. with open(test_path, 'w') as f:
  17. f.write("1234")
  18. assert plock.is_locked() is False
  19.  
  20. with open(test_path, 'w') as f:
  21. f.write(str(os.getpid()))
  22. assert plock.is_locked() is True
  23.  
  24. # any other cases that make sense ///
  25.  
  26. os.remove(test_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement