Add before assert helper and print console bytes on fail

sigintsaviour_citesthackin
Tyler Goodlet 2022-07-14 20:35:14 -04:00
parent b659326d5b
commit c132b7f624
1 changed files with 27 additions and 5 deletions

View File

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