From bc1cb6333b8912c938cc49d18f08574d256d41f5 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Wed, 25 Feb 2015 15:59:04 -0500 Subject: [PATCH] More tests of Semaphore, timeout, and with-statement. --- tornado/test/locks_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tornado/test/locks_test.py b/tornado/test/locks_test.py index 45db095ff..314530f56 100644 --- a/tornado/test/locks_test.py +++ b/tornado/test/locks_test.py @@ -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() -- 2.47.2