Skip to content

Commit 48dcdd1

Browse files
committed
capture logged error
1 parent 482eee6 commit 48dcdd1

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

Diff for: tests/test_core/test_layout.py

+26-18
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,33 @@ def OkChild():
142142

143143
@idom.component
144144
def BadChild():
145-
raise ValueError("Something went wrong :(")
145+
raise ValueError("error from bad child")
146146

147-
with idom.Layout(Main()) as layout:
148-
patch = await render_json_patch(layout)
149-
assert_same_items(
150-
patch.changes,
151-
[
152-
{
153-
"op": "add",
154-
"path": "/children",
155-
"value": [
156-
{"tagName": "div", "children": ["hello"]},
157-
{"tagName": "", "error": "ValueError: Something went wrong :("},
158-
{"tagName": "div", "children": ["hello"]},
159-
],
160-
},
161-
{"op": "add", "path": "/tagName", "value": "div"},
162-
],
163-
)
147+
with assert_idom_logged(
148+
match_error="error from bad child",
149+
clear_matched_records=True,
150+
):
151+
152+
with idom.Layout(Main()) as layout:
153+
patch = await render_json_patch(layout)
154+
assert_same_items(
155+
patch.changes,
156+
[
157+
{
158+
"op": "add",
159+
"path": "/children",
160+
"value": [
161+
{"tagName": "div", "children": ["hello"]},
162+
{
163+
"tagName": "",
164+
"error": "ValueError: Something went wrong :(",
165+
},
166+
{"tagName": "div", "children": ["hello"]},
167+
],
168+
},
169+
{"op": "add", "path": "/tagName", "value": "div"},
170+
],
171+
)
164172

165173

166174
@pytest.mark.skipif(

0 commit comments

Comments
 (0)