Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 12
0
 def _pop(self):
     self.fn = self._test_fn()
     pop = pmemobj.create(self.fn)
     self.addCleanup(pop.close)
     return pop
Ejemplo n.º 13
0
 def test_implicit_close_after_create(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     del pop
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 16
0
 def test_implicit_close_after_create(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     del pop
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 22
0
 def test_duplicate_close(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop.close()
Ejemplo n.º 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()
Ejemplo n.º 24
0
 def test_duplicate_close(self):
     fn = self._test_fn()
     pop = pmemobj.create(fn)
     pop.close()
     pop.close()
Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 27
0
 def _pop(self):
     self.fn = self._test_fn()
     pop = pmemobj.create(self.fn)
     self.addCleanup(pop.close)
     return pop
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)