mirror of
				https://github.com/python/cpython.git
				synced 2025-10-26 11:14:33 +00:00 
			
		
		
		
	 04f357cffe
			
		
	
	
		04f357cffe
		
	
	
	
	
		
			
			imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			856 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			856 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
| #! /usr/bin/env python
 | |
| """Test script for the gdbm module
 | |
|    Roger E. Masse
 | |
| """
 | |
| 
 | |
| import gdbm
 | |
| from gdbm import error
 | |
| from test.test_support import verbose, verify, TestFailed
 | |
| 
 | |
| filename= '/tmp/delete_me'
 | |
| 
 | |
| g = gdbm.open(filename, 'c')
 | |
| verify(g.keys() == [])
 | |
| g['a'] = 'b'
 | |
| g['12345678910'] = '019237410982340912840198242'
 | |
| a = g.keys()
 | |
| if verbose:
 | |
|     print 'Test gdbm file keys: ', a
 | |
| 
 | |
| g.has_key('a')
 | |
| g.close()
 | |
| try:
 | |
|     g['a']
 | |
| except error:
 | |
|     pass
 | |
| else:
 | |
|     raise TestFailed, "expected gdbm.error accessing closed database"
 | |
| g = gdbm.open(filename, 'r')
 | |
| g.close()
 | |
| g = gdbm.open(filename, 'w')
 | |
| g.close()
 | |
| g = gdbm.open(filename, 'n')
 | |
| g.close()
 | |
| try:
 | |
|     g = gdbm.open(filename, 'rx')
 | |
|     g.close()
 | |
| except error:
 | |
|     pass
 | |
| else:
 | |
|     raise TestFailed, "expected gdbm.error when passing invalid open flags"
 | |
| 
 | |
| try:
 | |
|     import os
 | |
|     os.unlink(filename)
 | |
| except:
 | |
|     pass
 |