Пример #1
0
    def test_block_start_string(self):
        original = "# KIGEN_start foo arg1:a arg2:b\n# KIGEN_end"
        blocks = kigen.extract_blocks(original)
        assert len(blocks) == 1

        boi = blocks[0]
        start_str = kigen.block_to_start_string(boi)

        assert start_str == "# KIGEN_start foo arg1:a arg2:b"
Пример #2
0
    def test_recombine(self):
        blocks = kigen.extract_blocks(_test_block3)
        render_blocks = [
            '{}\n{}'.format(kigen.block_to_start_string(x),
                            kigen.block_to_end_string(x)) for x in blocks
        ]
        file_chunks = kigen.split_file_at_blocks(_test_block3, blocks)

        result = kigen.recombine(file_chunks, render_blocks)
        assert result.strip() == _test_block3.strip()
Пример #3
0
    def test_block_extraction(self):
        blocks = kigen.extract_blocks(_test_block)
        assert len(blocks) == len(_block_positions)

        for idx, block in enumerate(blocks):
            assert block.start == _block_positions[idx][0]
            assert block.end == _block_positions[idx][1]
            assert block.command.module == _block_funcs[idx]
            assert len(block.command.args) == len(_block_args[idx])
            for arg in block.command.args:
                assert block.command.args[arg] == _block_args[idx][arg]
Пример #4
0
 def test_split_at_blocks_no_lead_in(self):
     blocks = kigen.extract_blocks(_test_block2)
     file_chunks = kigen.split_file_at_blocks(_test_block2, blocks)
     assert file_chunks == _test_block2_content