Skip to content

Commit 54af0d4

Browse files
committed
Add before assert helper and print console bytes on fail
1 parent 5947e93 commit 54af0d4

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

tests/test_debugger.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ def _spawn(cmd):
7373
return _spawn
7474

7575

76+
def assert_before(
77+
child,
78+
patts: list[str],
79+
80+
) -> None:
81+
82+
before = str(child.before.decode())
83+
84+
for patt in patts:
85+
try:
86+
assert patt in before
87+
except AssertionError:
88+
print(before)
89+
raise
90+
91+
7692
@pytest.fixture(
7793
params=[False, True],
7894
ids='ctl-c={}'.format,
@@ -163,6 +179,8 @@ def do_ctlc(
163179
time.sleep(delay)
164180
child.sendcontrol('c')
165181

182+
before = str(child.before.decode())
183+
166184
# TODO: figure out why this makes CI fail..
167185
# if you run this test manually it works just fine..
168186
from conftest import _ci_env
@@ -175,8 +193,6 @@ def do_ctlc(
175193
# should see the last line on console
176194
assert patt in before
177195

178-
before = str(child.before.decode())
179-
180196

181197
def test_root_actor_bp_forever(
182198
spawn,
@@ -365,9 +381,15 @@ def test_multi_subactors(
365381

366382
# 2nd name_error failure
367383
child.expect(r"\(Pdb\+\+\)")
368-
before = str(child.before.decode())
369-
assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
370-
assert "NameError" in before
384+
385+
assert_before(child, [
386+
"Attaching to pdb in crashed actor: ('name_error_1'",
387+
"NameError",
388+
])
389+
390+
# before = str(child.before.decode())
391+
# assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
392+
# assert "NameError" in before
371393

372394
if ctlc:
373395
do_ctlc(child)

0 commit comments

Comments
 (0)