summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dummy_thread.py
diff options
context:
space:
mode:
authorJoost Lek <vlabakje@gmail.com>2019-06-17 08:10:17 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-06-17 08:10:17 (GMT)
commitc5905f39bcf4ef895d42eede41bb5a2f071a501d (patch)
tree291b248c39f8e5cd4ea3ebe8955a0f2d7b25f0e8 /Lib/test/test_dummy_thread.py
parent28fca0c422b425a6be43be31add0a5328c16b0b8 (diff)
downloadcpython-c5905f39bcf4ef895d42eede41bb5a2f071a501d.zip
cpython-c5905f39bcf4ef895d42eede41bb5a2f071a501d.tar.gz
cpython-c5905f39bcf4ef895d42eede41bb5a2f071a501d.tar.bz2
bpo-36688: Adding an implementation of RLock in _dummy_thread (GH-12943)
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 da51216..0f56fcf 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()