Changeset 745 for trunk/server/lib/tdb/python
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/lib/tdb/python/tdbdump.py
r414 r745 1 #!/usr/bin/ python1 #!/usr/bin/env python 2 2 # Trivial reimplementation of tdbdump in Python 3 3 -
trunk/server/lib/tdb/python/tests/simple.py
r414 r745 1 #!/usr/bin/ python1 #!/usr/bin/env python 2 2 # Some simple tests for the Python bindings for TDB 3 3 # Note that this tests the interface of the Python bindings … … 13 13 14 14 class OpenTdbTests(TestCase): 15 15 16 def test_nonexistant_read(self): 16 self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR) 17 self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, 18 tdb.DEFAULT, os.O_RDWR) 17 19 18 20 class CloseTdbTests(TestCase): 21 19 22 def test_double_close(self): 20 self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR) 23 self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, 24 os.O_CREAT|os.O_RDWR) 21 25 self.assertNotEqual(None, self.tdb) 22 26 … … 26 30 27 31 32 class InternalTdbTests(TestCase): 33 34 def test_repr(self): 35 self.tdb = tdb.Tdb() 36 37 # repr used to crash on internal db 38 self.assertEquals(repr(self.tdb), "Tdb(<internal>)") 39 40 28 41 class SimpleTdbTests(TestCase): 42 29 43 def setUp(self): 30 44 super(SimpleTdbTests, self).setUp() 31 self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR) 45 self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, 46 os.O_CREAT|os.O_RDWR) 32 47 self.assertNotEqual(None, self.tdb) 33 48 … … 82 97 self.tdb.map_size 83 98 99 def test_freelist_size(self): 100 self.tdb.freelist_size 101 84 102 def test_name(self): 85 103 self.tdb.filename … … 104 122 self.assertEquals("1", self.tdb["bloe"]) 105 123 106 def test_ iterator(self):124 def test_transaction_prepare_commit(self): 107 125 self.tdb["bloe"] = "2" 108 self.tdb["bla"] = "hoi" 109 i = iter(self.tdb) 110 self.assertEquals(set(["bloe", "bla"]), set([i.next(), i.next()])) 126 self.tdb.transaction_start() 127 self.tdb["bloe"] = "1" 128 self.tdb.transaction_prepare_commit() 129 self.tdb.transaction_commit() 130 self.assertEquals("1", self.tdb["bloe"]) 111 131 112 132 def test_iterkeys(self): … … 123 143 self.assertEquals(0, len(list(self.tdb))) 124 144 145 def test_repack(self): 146 self.tdb["foo"] = "abc" 147 self.tdb["bar"] = "def" 148 del self.tdb["foo"] 149 self.tdb.repack() 150 151 def test_seqnum(self): 152 self.tdb.enable_seqnum() 153 seq1 = self.tdb.seqnum 154 self.tdb.increment_seqnum_nonblock() 155 seq2 = self.tdb.seqnum 156 self.assertEquals(seq2-seq1, 1) 157 125 158 def test_len(self): 126 159 self.assertEquals(0, len(list(self.tdb))) … … 128 161 self.assertEquals(1, len(list(self.tdb))) 129 162 163 def test_add_flags(self): 164 self.tdb.add_flags(tdb.NOMMAP) 165 self.tdb.remove_flags(tdb.NOMMAP) 166 167 168 class VersionTests(TestCase): 169 170 def test_present(self): 171 self.assertTrue(isinstance(tdb.__version__, str)) 172 130 173 131 174 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.