11from __future__ import unicode_literals
22
3+ import logging
34import sys
45import threading
56
910
1011
1112@pytest .mark .parametrize ("lock_type" , [FileLock , SoftFileLock ])
12- def test_simple (lock_type , tmp_path ):
13+ def test_simple (lock_type , tmp_path , caplog ):
14+ caplog .set_level (logging .DEBUG )
1315 lock_path = tmp_path / "a"
1416 lock = lock_type (str (lock_path ))
1517
@@ -18,6 +20,14 @@ def test_simple(lock_type, tmp_path):
1820 assert lock is locked
1921 assert not lock .is_locked
2022
23+ assert caplog .messages == [
24+ "Attempting to acquire lock {} on {}" .format (id (lock ), lock_path ),
25+ "Lock {} acquired on {}" .format (id (lock ), lock_path ),
26+ "Attempting to release lock {} on {}" .format (id (lock ), lock_path ),
27+ "Lock {} released on {}" .format (id (lock ), lock_path ),
28+ ]
29+ assert [r .levelno for r in caplog .records ] == [logging .DEBUG , logging .DEBUG , logging .DEBUG , logging .DEBUG ]
30+
2131
2232@pytest .mark .parametrize ("lock_type" , [FileLock , SoftFileLock ])
2333def test_nested_context_manager (lock_type , tmp_path ):
0 commit comments