Exemplo n.º 1
0
    def test03_rnopen(self):
        data = "The quick brown fox jumped over the lazy dog.".split()
        if verbose:
            print "\nTesting: rnopen"

        f = rnopen(self.filename, 'c')
        for x in range(len(data)):
            f[x + 1] = data[x]

        getTest = (f[1], f[2], f[3])
        if verbose:
            print '%s %s %s' % getTest

        self.assertEqual(getTest[1], 'quick', 'data mismatch!')

        rv = f.set_location(3)
        if rv != (3, 'brown'):
            self.fail('recno database set_location failed: ' + repr(rv))

        f[25] = 'twenty-five'
        f.close()
        del f

        f = rnopen(self.filename, 'w')
        f[20] = 'twenty'

        def noRec(f):
            rec = f[15]

        self.assertRaises(KeyError, noRec, f)

        def badKey(f):
            rec = f['a string']

        self.assertRaises(TypeError, badKey, f)

        del f[3]

        rec = f.first()
        while rec:
            if verbose:
                print rec
            try:
                rec = f.next()
            except KeyError:
                break

        f.close()
Exemplo n.º 2
0
    def test03_rnopen(self):
        data = "The quick brown fox jumped over the lazy dog.".split()
        if verbose:
            print "\nTesting: rnopen"

        f = rnopen(self.filename, 'c')
        for x in range(len(data)):
            f[x+1] = data[x]

        getTest = (f[1], f[2], f[3])
        if verbose:
            print '%s %s %s' % getTest

        self.assertEqual(getTest[1], 'quick', 'data mismatch!')

        rv = f.set_location(3)
        if rv != (3, 'brown'):
            self.fail('recno database set_location failed: '+repr(rv))

        f[25] = 'twenty-five'
        f.close()
        del f

        f = rnopen(self.filename, 'w')
        f[20] = 'twenty'

        def noRec(f):
            rec = f[15]
        self.assertRaises(KeyError, noRec, f)

        def badKey(f):
            rec = f['a string']
        self.assertRaises(TypeError, badKey, f)

        del f[3]

        rec = f.first()
        while rec:
            if verbose:
                print rec
            try:
                rec = f.next()
            except KeyError:
                break

        f.close()
Exemplo n.º 3
0
    def test03_rnopen(self):
        data = "The quick brown fox jumped over the lazy dog.".split()
        if verbose:
            print "\nTesting: rnopen"
        f = rnopen(self.filename, "c")
        for x in range(len(data)):
            f[x + 1] = data[x]

        getTest = (f[1], f[2], f[3])
        if verbose:
            print "%s %s %s" % getTest
        self.assertEqual(getTest[1], "quick", "data mismatch!")
        rv = f.set_location(3)
        if rv != (3, "brown"):
            self.fail("recno database set_location failed: " + repr(rv))
        f[25] = "twenty-five"
        f.close()
        del f
        f = rnopen(self.filename, "w")
        f[20] = "twenty"

        def noRec(f):
            rec = f[15]

        self.assertRaises(KeyError, noRec, f)

        def badKey(f):
            rec = f["a string"]

        self.assertRaises(TypeError, badKey, f)
        del f[3]
        rec = f.first()
        while rec:
            if verbose:
                print rec
            try:
                rec = f.next()
            except KeyError:
                break

        f.close()