test_protobuf_descs.py 847 字节
Newer Older
Y
Update  
Yu Yang 已提交
1 2 3 4 5 6 7 8 9 10 11
import unittest
import paddle.v2.framework.core as core


class TestProgramDesc(unittest.TestCase):
    def test_instance(self):
        program_desc = core.ProgramDesc.instance()
        self.assertIsNotNone(program_desc)
        del program_desc
        program_desc = core.ProgramDesc.instance()
        self.assertIsNotNone(program_desc)
Y
Yu Yang 已提交
12
        self.assertIsNotNone(program_desc.root_block())
Y
Update  
Yu Yang 已提交
13 14
        del program_desc

Y
Yu Yang 已提交
15 16 17 18 19 20 21 22
    def test_append_block(self):
        prog_desc = core.ProgramDesc.__create_program_desc__()
        self.assertIsNotNone(prog_desc)
        block1 = prog_desc.append_block(prog_desc.root_block())
        block2 = prog_desc.append_block(block1)
        self.assertEqual(block1.id(), block2.parent())
        self.assertEqual(prog_desc.root_block().id(), block1.parent())

Y
Update  
Yu Yang 已提交
23 24 25

if __name__ == '__main__':
    unittest.main()