]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
More tests of Semaphore, timeout, and with-statement. 1346/head
authorA. Jesse Jiryu Davis <jesse@mongodb.com>
Wed, 25 Feb 2015 20:59:04 +0000 (15:59 -0500)
committerA. Jesse Jiryu Davis <jesse@mongodb.com>
Wed, 25 Feb 2015 20:59:04 +0000 (15:59 -0500)
tornado/test/locks_test.py

index 45db095ff374854e0a354532ec7649aa6256c994..314530f5610d57ce836002427b9c2b8d8f7529dc 100644 (file)
@@ -296,11 +296,23 @@ class SemaphoreContextManagerTest(AsyncTestCase):
 
     @gen_test
     def test_context_manager_timeout(self):
+        sem = locks.Semaphore()
+        with (yield sem.acquire(timedelta(seconds=0.01))):
+            pass
+
+        # Semaphore was released and can be acquired again.
+        self.assertTrue(sem.acquire().done())
+
+    @gen_test
+    def test_context_manager_timeout_error(self):
         sem = locks.Semaphore(value=0)
         with self.assertRaises(gen.TimeoutError):
             with (yield sem.acquire(timedelta(seconds=0.01))):
                 pass
 
+        # Counter is still 0.
+        self.assertFalse(sem.acquire().done())
+
     @gen_test
     def test_context_manager_contended(self):
         sem = locks.Semaphore()