| 
									
										
										
										
											2003-02-12 23:02:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | import imp | 
					
						
							|  |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2003-02-17 14:51:41 +00:00
										 |  |  | from test_support import TestFailed, run_unittest | 
					
						
							| 
									
										
										
										
											2003-02-12 23:02:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-17 14:51:41 +00:00
										 |  |  | def test_main(): | 
					
						
							|  |  |  |     run_unittest(ImpLock) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-12 23:02:21 +00:00
										 |  |  | if __name__ == "__main__": | 
					
						
							| 
									
										
										
										
											2003-02-17 14:51:41 +00:00
										 |  |  |     test_main() |