Add before assert helper and print console bytes on fail

signint_saviour
Tyler Goodlet 2022-07-14 20:35:14 -04:00
parent 6bdcbdb96f
commit 4779badd96
1 changed files with 27 additions and 5 deletions

View File

@ -73,6 +73,22 @@ def spawn(
return _spawn
def assert_before(
child,
patts: list[str],
) -> None:
before = str(child.before.decode())
for patt in patts:
try:
assert patt in before
except AssertionError:
print(before)
raise
@pytest.fixture(
params=[False, True],
ids='ctl-c={}'.format,
@ -163,6 +179,8 @@ def do_ctlc(
time.sleep(delay)
child.sendcontrol('c')
before = str(child.before.decode())
# TODO: figure out why this makes CI fail..
# if you run this test manually it works just fine..
from conftest import _ci_env
@ -175,8 +193,6 @@ def do_ctlc(
# should see the last line on console
assert patt in before
before = str(child.before.decode())
def test_root_actor_bp_forever(
spawn,
@ -365,9 +381,15 @@ def test_multi_subactors(
# 2nd name_error failure
child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode())
assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
assert "NameError" in before
assert_before(child, [
"Attaching to pdb in crashed actor: ('name_error_1'",
"NameError",
])
# before = str(child.before.decode())
# assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
# assert "NameError" in before
if ctlc:
do_ctlc(child)