def _test_write_read_object_2(self, obj, file_path, format_name): self.assertFalse(os.path.exists(file_path)) writer = write_object(obj, file_path, format_name=format_name) self.assertIsNotNone(writer) self.assertTrue(os.path.isfile(file_path)) obj, reader = read_object(file_path) self.assertIsNotNone(obj) self.assertIsNotNone(reader)
def _test_write_read_object(self, obj, file_path, format_name): if os.path.exists(file_path): os.remove(file_path) self.assertFalse(os.path.exists(file_path)) writer = write_object(obj, file_path, format_name=format_name) self.assertIsNotNone(writer) self.assertTrue(os.path.isfile(file_path)) obj, reader = read_object(file_path) self.assertIsNotNone(obj) self.assertIsNotNone(reader) if hasattr(obj, 'close'): obj.close() os.remove(file_path)