summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_imp.py
blob: 22e25ba5ec57f928ee3eaff3c667b0e5580064f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

import imp
import unittest
from test.test_support import TestFailed, run_unittest

class ImpLock(unittest.TestCase):

    # XXX this test is woefully inadequate, please fix me
    def testLock(self):
        LOOPS = 50
        for i in range(LOOPS):
            imp.acquire_lock()
        for i in range(LOOPS):
            imp.release_lock()

        for i in range(LOOPS):
            try:
                imp.release_lock()
            except RuntimeError:
                pass
            else:
                raise TestFailed, \
                    "release_lock() without lock should raise RuntimeError"

def test_main():
    run_unittest(ImpLock)

if __name__ == "__main__":
    test_main()