Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Nov 25, 2024
1 parent ddb1a2a commit af6734f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion bluebell/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,15 @@ def to_dict(self):
'type': 'block',
'name': 'block',
'children': kids,
'attribs': {'name': 'block'},
'attribs': {},
}

if self.attrs.text:
info['attribs'].update(self.attrs.to_dict())

if not info['attribs'].get('name'):
info['attribs']['name'] = 'block'

return info


Expand Down
16 changes: 11 additions & 5 deletions tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,22 @@ def test_generic_block(self):
BLOCK.cls{a b}
foo
ITEMS
ITEM bar
ITEM baz
end
BLOCK{name my-block}
foo
bar
BLOCK{name }
bad name
BLOCK
tail
""", 'hier_element_block')
xml = self.tostring(self.to_xml(tree.to_dict()))
Expand All @@ -460,6 +463,9 @@ def test_generic_block(self):
<p eId="part_A__block_2__p_1">foo</p>
<p eId="part_A__block_2__p_2">bar</p>
</block>
<block eId="part_A__block_3" name="block">
<p eId="part_A__block_3__p_1">bad name</p>
</block>
<p eId="part_A__p_1">BLOCK</p>
<p eId="part_A__p_2">tail</p>
</content>
Expand Down

0 comments on commit af6734f

Please sign in to comment.