diff --git a/flameshow/models.py b/flameshow/models.py index 4d04088..e4396e7 100644 --- a/flameshow/models.py +++ b/flameshow/models.py @@ -101,9 +101,9 @@ def render_one_frame_detail( raise NotImplementedError @property - def title(self) -> str: + def title(self) -> Text: """Full name which will be displayed in the frame detail panel""" - return self.name + return Text(self.name) @property def color_key(self): diff --git a/tests/stackcollapse_data/simple_square.txt b/tests/stackcollapse_data/simple_square.txt new file mode 100644 index 0000000..83bd2b1 --- /dev/null +++ b/tests/stackcollapse_data/simple_square.txt @@ -0,0 +1,2 @@ +a;b;[c] 1 +a;[b];d 4 diff --git a/tests/test_stackcollapse_parse/test_model.py b/tests/test_stackcollapse_parse/test_model.py index 67ec9ab..0ef68ec 100644 --- a/tests/test_stackcollapse_parse/test_model.py +++ b/tests/test_stackcollapse_parse/test_model.py @@ -1,3 +1,4 @@ +from rich.text import Text from flameshow.parsers.stackcollapse_parser import StackCollapseFrame @@ -6,4 +7,18 @@ def test_frame_model_render(): "java::abc", 1, parent=None, children=[], values=[13] ) render_result = f.render_one_frame_detail(f, 0, "count") - assert render_result == ["java::abc\n"] + assert len(render_result) == 1 + item = render_result[0] + assert item.markup == "java::abc\n" + + +def test_frame_model_render_with_square(): + f = StackCollapseFrame("[abc]", 1, parent=None, children=[], values=[13]) + render_result = f.render_one_frame_detail(f, 0, "count") + assert len(render_result) == 1 + item = render_result[0] + assert item.markup == "\\[abc]\n" + + title = f.title + assert isinstance(title, Text) + assert title.plain == "[abc]" diff --git a/tests/test_stackcollapse_parse/test_parser.py b/tests/test_stackcollapse_parse/test_parser.py index 3bce65c..862a94a 100644 --- a/tests/test_stackcollapse_parse/test_parser.py +++ b/tests/test_stackcollapse_parse/test_parser.py @@ -10,24 +10,20 @@ def test_parse_simple_text_data(simple_collapse_data): assert frame2json(profile.root_stack) == { "root": { - "children": [ - { - "a": { - "children": [ - { - "b": { - "children": [ - {"c": {"children": [], "values": [5]}}, - {"d": {"children": [], "values": [4]}}, - ], - "values": [14], - } - } - ], - "values": [14], - } + "children": [{ + "a": { + "children": [{ + "b": { + "children": [ + {"c": {"children": [], "values": [5]}}, + {"d": {"children": [], "values": [4]}}, + ], + "values": [14], + } + }], + "values": [14], } - ], + }], "values": [14], }, } @@ -98,16 +94,14 @@ def test_validate_simple_text_data_contains_numbers_somtimes_parsing(): "children": [ { "a": { - "children": [ - { - "b": { - "children": [ - {"c": {"children": [], "values": [10]}} - ], - "values": [10], - } + "children": [{ + "b": { + "children": [ + {"c": {"children": [], "values": [10]}} + ], + "values": [10], } - ], + }], "values": [10], } }, @@ -125,28 +119,24 @@ def test_space_and_numbers_in_stackcollapse_symbols(): profile = StackCollapseParser("a.txt").parse(data) assert frame2json(profile.root_stack) == { "root": { - "children": [ - { - "a 1": { - "children": [ - { - "b 2": { - "children": [ - { - "c 3": { - "children": [], - "values": [10], - } - } - ], - "values": [10], + "children": [{ + "a 1": { + "children": [{ + "b 2": { + "children": [ + { + "c 3": { + "children": [], + "values": [10], + } } - } - ], - "values": [10], - } + ], + "values": [10], + } + }], + "values": [10], } - ], + }], "values": [10], }, }