Beispiel #1
0
 def test_unknown_nonpersistent_type(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     with self.assertRaises(TypeError) as cm:
         pop.root = TestFoo()
     self.assertMsgBits(str(cm.exception), "on't know how", "TestFoo")
Beispiel #2
0
 def test_unknown_nonpersistent_type(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     with self.assertRaises(TypeError) as cm:
         pop.root = TestFoo()
     self.assertMsgBits(str(cm.exception), "on't know how", "TestFoo")
Beispiel #3
0
 def test_small_pool_size_error(self):
     fn = self._test_fn()
     with self.assertRaises(ValueError) as cm:
         pop = pmemobj.create(fn, pmemobj.MIN_POOL_SIZE-1)
     self.assertNotEqual(
         re.search(r"size ?\d+ smaller than %d" %
                   (pmemobj.MIN_POOL_SIZE), str(cm.exception)), None)
Beispiel #4
0
 def test_small_pool_size_error(self):
     fn = self._test_fn()
     with self.assertRaises(ValueError) as cm:
         pop = pmemobj.create(fn, pmemobj.MIN_POOL_SIZE - 1)
     self.assertNotEqual(
         re.search(r"size ?\d+ smaller than %d" % (pmemobj.MIN_POOL_SIZE),
                   str(cm.exception)), None)
Beispiel #5
0
 def _make_dict(self, *args, **kw):
     self.fn = self._test_fn()
     self.pop = pmemobj.create(self.fn,
                               pool_size=32 * 1024 * 1024,
                               debug=True)
     self.addCleanup(self.pop.close)
     self.pop.root = self.pop.new(pmemobj.PersistentDict, *args, **kw)
     return self.pop.root
Beispiel #6
0
    def _make_set(self, *args):
        if not hasattr(self, "pop"):
            self.fn = self._test_fn()
            self.pop = pmemobj.create(self.fn, pool_size=32*1024*1024,
                                      debug=True)
            self.pop.root = self.pop.new(pmemobj.PersistentList, [])
            self.addCleanup(self.pop.close)

        newset = self.pop.new(self.thetype, args[0] if len(args) > 0 else args)
        self.pop.root.append(newset)
        return newset
Beispiel #7
0
    def _make_set(self, *args):
        if not hasattr(self, "pop"):
            self.fn = self._test_fn()
            self.pop = pmemobj.create(self.fn,
                                      pool_size=32 * 1024 * 1024,
                                      debug=True)
            self.pop.root = self.pop.new(pmemobj.PersistentList, [])
            self.addCleanup(self.pop.close)

        newset = self.pop.new(self.thetype, args[0] if len(args) > 0 else args)
        self.pop.root.append(newset)
        return newset
Beispiel #8
0
 def test_list_of_strings_as_root_obj(self):
     # Lists and strings are our "built in" types (handled specially by the
     # code because they are used by the type table), so this exercises
     # the absolute minimum required functionality, but doesn't fully
     # exercise anything, including not really testing the type table.
     test_list = ['a', 'b', 'c', 'd']
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     pop.root = pop.new(pmemobj.PersistentList, test_list)
     pop.close()
     pop = pmemobj.open(fn)
     self.assertEqual(pop.root, test_list)
Beispiel #9
0
 def test_list_of_strings_as_root_obj(self):
     # Lists and strings are our "built in" types (handled specially by the
     # code because they are used by the type table), so this exercises
     # the absolute minimum required functionality, but doesn't fully
     # exercise anything, including not really testing the type table.
     test_list = ['a', 'b', 'c', 'd']
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     pop.root = pop.new(pmemobj.PersistentList, test_list)
     pop.close()
     pop = pmemobj.open(fn)
     self.assertEqual(pop.root, test_list)
Beispiel #10
0
 def _setup(self):
     self.fn = self._test_fn()
     pop = self.pop = pmemobj.create(self.fn)
     self.addCleanup(lambda: self.pop.close())
     return pop
Beispiel #11
0
 def test_implicit_close_after_open(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop = pmemobj.open(fn)
     del pop
Beispiel #12
0
 def _pop(self):
     self.fn = self._test_fn()
     pop = pmemobj.create(self.fn)
     self.addCleanup(pop.close)
     return pop
Beispiel #13
0
 def test_implicit_close_after_create(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     del pop
Beispiel #14
0
 def test_create_open_close_dont_raise(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop = pmemobj.open(fn)
     pop.close()
Beispiel #15
0
 def test_create_is_error_if_already_exists(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     with self.assertRaises(OSError):
         pmemobj.create(fn)
Beispiel #16
0
 def test_implicit_close_after_create(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     del pop
Beispiel #17
0
 def _make_list(self, arg):
     self.fn = self._test_fn()
     self.pop = pmemobj.create(self.fn, debug=True)
     self.addCleanup(self.pop.close)
     self.pop.root = self.pop.new(pmemobj.PersistentList, arg)
     return self.pop.root
Beispiel #18
0
 def _make_object(self, cls, *args, **kw):
     self.fn = self._test_fn()
     self.pop = pmemobj.create(self.fn, debug=True)
     self.addCleanup(self.pop.close)
     self.pop.root = self.pop.new(cls, *args, **kw)
     return self.pop.root
Beispiel #19
0
 def test_implicit_close_after_open(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop = pmemobj.open(fn)
     del pop
Beispiel #20
0
 def test_constructor_flag_x(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     with self.assertRaises(OSError):
         pmemobj.PersistentObjectPool(fn, flag='x')
Beispiel #21
0
 def test_create_is_error_if_already_exists(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     with self.assertRaises(OSError):
         pmemobj.create(fn)
Beispiel #22
0
 def test_duplicate_close(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop.close()
Beispiel #23
0
 def test_create_open_close_dont_raise(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop = pmemobj.open(fn)
     pop.close()
Beispiel #24
0
 def test_duplicate_close(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop.close()
Beispiel #25
0
 def _setup(self):
     self.fn = self._test_fn()
     pop = self.pop = pmemobj.create(self.fn)
     self.addCleanup(lambda: self.pop.close())
     return pop
Beispiel #26
0
 def test_constructor_flag_x(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     with self.assertRaises(OSError):
         pmemobj.PersistentObjectPool(fn, flag='x')
Beispiel #27
0
 def _pop(self):
     self.fn = self._test_fn()
     pop = pmemobj.create(self.fn)
     self.addCleanup(pop.close)
     return pop
Beispiel #28
0
 def _make_tuple(self, arg):
     self.fn = self._test_fn()
     self.pop = pmemobj.create(self.fn, debug=True)
     self.addCleanup(self.pop.close)
     self.pop.root = self.pop.new(pmemobj.PersistentTuple, arg)
     return self.pop.root
Beispiel #29
0
 def test_filename_is_preserved(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     self.assertEqual(pop.filename, fn)
Beispiel #30
0
 def _make_dict(self, *args, **kw):
     self.fn = self._test_fn()
     self.pop = pmemobj.create(self.fn, pool_size=32*1024*1024, debug=True)
     self.addCleanup(self.pop.close)
     self.pop.root = self.pop.new(pmemobj.PersistentDict, *args, **kw)
     return self.pop.root
Beispiel #31
0
 def test_filename_is_preserved(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     self.addCleanup(pop.close)
     self.assertEqual(pop.filename, fn)