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")
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)
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)
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
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
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
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)
def _setup(self): self.fn = self._test_fn() pop = self.pop = pmemobj.create(self.fn) self.addCleanup(lambda: self.pop.close()) return pop
def test_implicit_close_after_open(self): fn = self._test_fn() pop = pmemobj.create(fn) pop.close() pop = pmemobj.open(fn) del pop
def _pop(self): self.fn = self._test_fn() pop = pmemobj.create(self.fn) self.addCleanup(pop.close) return pop
def test_implicit_close_after_create(self): fn = self._test_fn() pop = pmemobj.create(fn) del pop
def test_create_open_close_dont_raise(self): fn = self._test_fn() pop = pmemobj.create(fn) pop.close() pop = pmemobj.open(fn) pop.close()
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)
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
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
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')
def test_duplicate_close(self): fn = self._test_fn() pop = pmemobj.create(fn) pop.close() pop.close()
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
def test_filename_is_preserved(self): fn = self._test_fn() pop = pmemobj.create(fn) self.addCleanup(pop.close) self.assertEqual(pop.filename, fn)
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