summaryrefslogtreecommitdiff
path: root/Lib/test/test_dummy_thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_dummy_thread.py')
-rw-r--r--Lib/test/test_dummy_thread.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py
index da51216783..0f56fcf973 100644
--- a/Lib/test/test_dummy_thread.py
+++ b/Lib/test/test_dummy_thread.py
@@ -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()