tdb: add tests for double .close() in pytdb
[kai/samba.git] / lib / tdb / python / tests / simple.py
index d242e665beb971c0934ed5e7143d8d445e51cb56..c7443c0d433526054190c6ce80d66e4866196cb9 100644 (file)
@@ -15,6 +15,15 @@ class OpenTdbTests(TestCase):
     def test_nonexistant_read(self):
         self.assertRaises(IOError, tdb.Tdb, "/some/nonexistant/file", 0, tdb.DEFAULT, os.O_RDWR)
 
+class CloseTdbTests(TestCase):
+    def test_double_close(self):
+        self.tdb = tdb.Tdb(tempfile.mkstemp()[1], 0, tdb.DEFAULT, os.O_CREAT|os.O_RDWR)
+        self.assertNotEqual(None, self.tdb)
+
+        # ensure that double close does not crash python
+        self.tdb.close()
+        self.tdb.close()
+
 
 class SimpleTdbTests(TestCase):
     def setUp(self):