All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lib-python.2.5.test.test_gdbm.py Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
#! /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, TESTFN

filename = TESTFN

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy