2 import test
.test_support
4 mutex
= test
.test_support
.import_module("mutex", deprecated
=True)
6 class MutexTest(unittest
.TestCase
):
8 def test_lock_and_unlock(self
):
10 def called_by_mutex(some_data
):
11 self
.assertEqual(some_data
, "spam")
12 self
.assertTrue(m
.test(), "mutex not held")
14 m
.lock(called_by_mutex2
, "eggs")
16 def called_by_mutex2(some_data
):
17 self
.assertEquals(some_data
, "eggs")
18 self
.assertTrue(m
.test(), "mutex not held")
19 self
.assertTrue(ready_for_2
,
20 "called_by_mutex2 called too soon")
24 m
.lock(called_by_mutex
, "spam")
29 self
.assertFalse(m
.test(), "mutex still held")
32 test
.test_support
.run_unittest(MutexTest
)
34 if __name__
== "__main__":