def _test43_emit_in_place(self): tree = ryml.parse_in_arena(self.src_as_bytearray) yaml = ryml.emit(tree) length = ryml.compute_emit_length(tree) self.assertEqual(len(yaml), length) buf = bytearray(length) s = ryml.emit_in_place(tree, buf) self.assertEqual(len(s), length) self.assertTrue(s.tobytes().decode('utf-8') == yaml) self.assertTrue(buf.decode('utf-8') == yaml)
def _test44_short_buf(self): tree = ryml.parse_in_arena(self.src_as_bytearray) length = ryml.compute_emit_length(tree) buf = bytearray(length - 1) with self.assertRaises(IndexError): ryml.emit_in_place(tree, buf)
def _test41_emit(self): tree = ryml.parse_in_arena(self.src_as_bytearray) yaml = ryml.emit(tree) output_tree = ryml.parse_in_arena(yaml) self.case.check(self, output_tree)
def _test42_compute_emit_length(self): tree = ryml.parse_in_arena(self.src_as_bytearray) yaml = ryml.emit(tree) length = ryml.compute_emit_length(tree) self.assertEqual(len(yaml), length)
def _test32_bytearray__ro__reuse_tree(self): t = ryml.Tree() r = ryml.parse_in_arena(self.src_as_bytearray, tree=t) self.assertTrue(r is t) self.case.check(self, t)
def _test31_bytearray__ro(self): tree = ryml.parse_in_arena(self.src_as_bytearray) self.case.check(self, tree)
def _test21_bytes__ro(self): tree = ryml.parse_in_arena(self.src_as_bytes) self.case.check(self, tree)
def _test12_str__ro__reuse_tree( self): # cannot read string buffers (or can we?) t = ryml.Tree() ryml.parse_in_arena(self.src_as_str, tree=t) self.case.check(self, t)
def _test11_str__ro(self): # cannot read string buffers (or can we?) tree = ryml.parse_in_arena(self.src_as_str) self.case.check(self, tree)