3 from test import test_support
6 class LockTests(unittest.TestCase):
8 """Very basic test of import lock functions."""
10 def verify_lock_state(self, expected):
11 self.failUnlessEqual(imp.lock_held(), expected,
12 "expected imp.lock_held() to be %r" % expected)
16 # The import lock may already be held, e.g. if the test suite is run
17 # via "import test.autotest".
18 lock_held_at_start = imp.lock_held()
19 self.verify_lock_state(lock_held_at_start)
21 for i in range(LOOPS):
23 self.verify_lock_state(True)
25 for i in range(LOOPS):
28 # The original state should be restored now.
29 self.verify_lock_state(lock_held_at_start)
31 if not lock_held_at_start:
37 self.fail("release_lock() without lock should raise "
40 class ReloadTests(unittest.TestCase):
42 """Very basic tests to make sure that imp.reload() operates just like
45 def test_source(self):
49 def test_extension(self):
53 def test_builtin(self):
67 tests.append(LockTests)
68 test_support.run_unittest(*tests)
70 if __name__ == "__main__":