mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
bpo-36688: Adding an implementation of RLock in _dummy_thread (GH-12943)
(cherry picked from commit c5905f39bc
)
Co-authored-by: Joost Lek <vlabakje@gmail.com>
This commit is contained in:
parent
e784f9f1c3
commit
ad505918a1
2 changed files with 52 additions and 1 deletions
|
@ -102,6 +102,24 @@ class LockTests(unittest.TestCase):
|
|||
self.assertIn("unlocked", repr(self.lock))
|
||||
|
||||
|
||||
class RLockTests(unittest.TestCase):
|
||||
"""Test dummy RLock objects."""
|
||||
|
||||
def setUp(self):
|
||||
self.rlock = _thread.RLock()
|
||||
|
||||
def test_multiple_acquire(self):
|
||||
self.assertIn("unlocked", repr(self.rlock))
|
||||
self.rlock.acquire()
|
||||
self.rlock.acquire()
|
||||
self.assertIn("locked", repr(self.rlock))
|
||||
self.rlock.release()
|
||||
self.assertIn("locked", repr(self.rlock))
|
||||
self.rlock.release()
|
||||
self.assertIn("unlocked", repr(self.rlock))
|
||||
self.assertRaises(RuntimeError, self.rlock.release)
|
||||
|
||||
|
||||
class MiscTests(unittest.TestCase):
|
||||
"""Miscellaneous tests."""
|
||||
|
||||
|
@ -253,3 +271,6 @@ class ThreadTests(unittest.TestCase):
|
|||
func = mock.Mock(side_effect=Exception)
|
||||
_thread.start_new_thread(func, tuple())
|
||||
self.assertTrue(mock_print_exc.called)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue