diff options
author | Garrett Berg <googberg@gmail.com> | 2017-12-07 18:04:26 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2017-12-07 18:04:26 (GMT) |
commit | a0374dd34aa25f0895195d388b5ceff43b121b00 (patch) | |
tree | 3cfd4cd4116c28d44c0ac915af715c5a346f29e0 /Lib | |
parent | 961dbe0548e26394b7716d41423c61b1e2e58ef7 (diff) | |
download | cpython-a0374dd34aa25f0895195d388b5ceff43b121b00.zip cpython-a0374dd34aa25f0895195d388b5ceff43b121b00.tar.gz cpython-a0374dd34aa25f0895195d388b5ceff43b121b00.tar.bz2 |
bpo-32208: update threading.Semaphore docs and add unit test (#4709)
* fix issue32208: update threading.Semaphore docs and add unit test to validate correct behavior
* add test for blocking
* Update threading.rst
* semaphore: remove documentation validation tests and move 'return value' test to BaseSemaphore
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/lock_tests.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index a1ea96d..5b1f033 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -629,13 +629,14 @@ class BaseSemaphoreTests(BaseTestCase): sem = self.semtype(7) sem.acquire() N = 10 + sem_results = [] results1 = [] results2 = [] phase_num = 0 def f(): - sem.acquire() + sem_results.append(sem.acquire()) results1.append(phase_num) - sem.acquire() + sem_results.append(sem.acquire()) results2.append(phase_num) b = Bunch(f, 10) b.wait_for_started() @@ -659,6 +660,7 @@ class BaseSemaphoreTests(BaseTestCase): # Final release, to let the last thread finish sem.release() b.wait_for_finished() + self.assertEqual(sem_results, [True] * (6 + 7 + 6 + 1)) def test_try_acquire(self): sem = self.semtype(2) |